I am getting this error when I try to use the .ix attribute of a pandas data frame to pull out a column, e.g. df.ix[:, 'col_header']
.
AttributeError: 'DataFrame' object has no attribute 'ix'
The script worked this morning, but this afternoon I ran it in a new Linux environment with a fresh install of Pandas. Has anybody else seen this error before? I've searched here and elsewhere but can't find it.
loc[] is used to select rows and columns by Names/Labels. iloc[] is used to select rows and columns by Integer Index/Position. zero based index position.
To convert the last or specific column of the Pandas dataframe to series, use the integer-location-based index in the df. iloc[:,0] . For example, we want to convert the third or last column of the given data from Pandas dataframe to series.
try df.iloc[:, integer]
.ix
is deprecated
By the way, df.loc[:,'col_header']
is for str or Boolean indexing
Change .ix to .loc and it should work correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With