AttributeError: 'Series' object has no attribute 'to_numeric'
15,721
import pandas as pd
tables = pd.read_html("https://www.sec.gov/Archives/edgar/data/949012/000156761919015285/xslForm13F_X01/form13fInfoTable.xml")
len(tables)
ren=tables[3]
ren.drop(ren.index[[0,1,2]], inplace=True)
ren[3] = pd.to_numeric(ren[3], errors='coerce')
ren.sort_values([3],ascending=False, inplace=True)
ren
0 1 2 3 ...
101 JPMorgan COM 46625h100 48532 ...
44 Cisco COM 17275r102 47376 ...
204 Waste Management COM 94106L109 41558 ...
117 Microsoft COM 594918104 37492 ...
99 Johnson & Johnson COM 478160104 31491 ...
Related videos on Youtube
Author by
IgBell
Updated on June 04, 2022Comments
-
IgBell almost 2 years
I'm trying to sort dataframe by values. got an AttributeError: 'Series' object has no attribute 'to_numeric'. version '0.20.3', so to numeric should work, but not. Please help.
import pandas as pd tables = pd.read_html("https://www.sec.gov/Archives/edgar/data/949012/000156761919015285/xslForm13F_X01/form13fInfoTable.xml") len(tables) ren=tables[3] ren.drop(ren.index[[0,1,2]], inplace=True) ren.to_numeric(ren[3], errors='coerce') #ren[3].convert_objects(convert_numeric=True) ren.sort_values(by=[3],ascending=False)
-
Derek Eden over 4 yearspandas.pydata.org/pandas-docs/stable/reference/api/… its a pd function not a series method
-
vb_rises over 4 years
pd.to_numeric(ren[3], errors='coerce')
-
Rajith Thennakoon over 4 yearsconvert your series to dataframe
ren.to_frame()
and applyto_numeric
method -
vb_rises over 4 years@IgBell change to the line from
ren.to_numeric(ren[3], errors='coerce')
topd.to_numeric(ren[3], errors='coerce')
. -
IgBell over 4 years@RajithThennakoon got another error instead AttributeError: 'DataFrame' object has no attribute 'to_frame'
-
IgBell over 4 years@vb_rises got another error instead AttributeError: 'DataFrame' object has no attribute 'sort_value'
-
IgBell over 4 years@DerekEden so, how to fix it?
-
-
IgBell over 4 yearsAppreciate it!!! Thanks!!! Everything works now. I stumble on that for already 2 days. The best answer obviously!