0

Pandas apply(pd.Series), causing warnings "The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning."

I'm trying to split the column of dictionaries in the dataframe with:df['A'].apply(pd.Series), and then concat it with:df=pd.concat([df.drop(['A'], axis=1), df['A'].apply(pd.Series)], axis=1), but it is possible that the dictionary in that column is empty. If it is in fact empty i get this warnings: FutureWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning. The next thing that i tried to do was adding the dtype to the "pd.Series" like df['A'].apply.pd.Series(dtype=float) but it's causing the next error: raise ValueError("No objects to concatenate") ValueError: No objects to concatenate. What can i do to get rid of the warning messages?

Leteers
  • 3
  • 3

0 Answers0