Franco Piccolo

1

votes
2

answer
35

views

Apply function to two columns Pandas

I'm trying to apply a function that calculates the R2 score to two columns of a pandas data frame. It works if first I group by some other column but when applied to the whole dataframe it fails. This is the code that works: from sklearn.metrics import r2_score df = pd.DataFrame({'cat':['A','A','B',...
Franco Piccolo
1

votes
1

answer
0

views

Should I cast target class as float or integer?

In sklearn, should I cast the target class as an integer or float? Will it make a difference? I'm asking because I'm training a Neural Network and read in this question that having a class casted as float may cause issues. Then according to this question I think the answer is as Integer, but I would...
Franco Piccolo
1

votes
0

answer
62

views

How to deal with FutureWarning: Int64Index.flags is deprecated and will be removed in a future version?

I'm doing a Grid Search passing custom cross validation folds with a list with indices and getting this warning, Why I'm getting this warnings message? and how to avoid this warning? My indexes are type 'int64'. Note: I don't want to simply suppress the warning. I need a solution so that without a...
Franco Piccolo
1

votes
1

answer
988

views

Why Pandas gives AttributeError: 'SeriesGroupBy' object has no attribute 'pct'?

I'm trying to pass a user defined function pct to Pandas agg method, and it works if I only pass that function but it doesn't when I use the dictionary format for defining the functions. Does anyone know why? import pandas as pd df = pd.DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]], columns=['A', 'B',...
Franco Piccolo
2

votes
2

answer
43

views

Join pandas row with column

I have this row dataframe: df = pd.DataFrame({'make':'toyota', 'model':'yaris'}, index=[0]) df make model 0 toyota yaris And have this other column dataframe: df_prices = pd.DataFrame({'prices':[1,2,3,4]}) df_prices prices 0 1 1 2 2 3 3 4 And I would like to join them to obtain: make...
Franco Piccolo
1

votes
4

answer
46

views

How to drop name from df.columns?

I would like to know how to remove the name from the df.columns attribute: Let's say I have the following dataframe with df.columns: df = pd.DataFrame({'a':[1,2,3], 'b':[4,5,6]}) df a b 0 1 4 1 2 5 2 3 6 df.columns Index(['a', 'b'], dtype='object') And then if I add a name to the colum...
Franco Piccolo