I have a DataFrame df:
A B
1 dog
cat XX
I have been trying to create a pandas DataFrame df_new that looks like this:
A B type_of_A type_of_B
1 dog int string
cat XX string whateverdtype it may be
I tried with:
df_new["type_of_A"] = [pd.api.types.infer_dtype(i) for i in range(df_new['A'].values)]
But I only got:
TypeError: only integer scalar arrays can be converted to a scalar index
Can anyone give me a hint? is this the right approach?
Thanks so much in advance