python - How to make dataframe in pandas as numeric? -


i learning book python data analysis, after running code book got pandas dataframe diversity this:

sex f m

year

1880 [38] [14]

1881 [38] [14]

when want use diversity.plot() draw pictures, there typeerror:

empty 'dataframe': no numeric data plot

so, question how deal dataframe make numeric?

it seems have list of int in data frame. convert need select value inside , form data frame.

i suggest code convert

for col in df: df[col] = df[col].apply(lambda x: x[0])


Comments