Given a dataframe such as:
page source_url count yes no ii dk
google.com youtube.com 3 0 0 1 2
facebook.com whatsapp.com 3 0 0 1 2
microsoft.com stackoverflow.com 3 0 0 1 2
I want to apply pd.to_numeric on the last 4 columns only.
I tried doing :
df['count'] = pd.to_numeric(df['count'])
df['yes'] = pd.to_numeric(df['yes'])
df['no'] = pd.to_numeric(df['no'])
df['ii'] = pd.to_numeric(df['i'])
df['dk'] = pd.to_numeric(df['dk'])
But the first line keeps giving me:
ValueError at /
Unable to parse string "<bound method Series.count of page https://www.snopes.com/fact-check/trump-suicid...
source_url https://www.facebook.com/candace.witte/posts/1...
count 0
Name: 7909, dtype: object>" at position 0
How can I use to_numeric() on some columns of a dataframe?
df.countin your code, either currently or in a prior function or iteration, to assign to thecountcolumn? It looks like you may have overwritten something in your namespace with the dataframe.count function signature, based onstring <bound method Series.count....countanywhere