If I reset the index of my Pandas dataframe with "inplace=True" (following the documentation) it returns a class 'NoneType'. If I reset the index with "inplace=False" it returns the dataframe with the new index. Why?
print(type(testDataframe))
print(testDataframe.head())
returns:
<class 'pandas.core.frame.DataFrame'>
ALandbouwBosbouwEnVisserij AantalInkomensontvangers AantalInwoners
0 73780.0 None 16979120
1 290.0 None 25243
2 20.0 None 3555
Set_index returns a new index:
testDataframe = testDataframe.set_index(['Codering'])
print(type(testDataframe))
print(testDataframe.head())
returns
<class 'pandas.core.frame.DataFrame'>
ALandbouwBosbouwEnVisserij AantalInkomensontvangers
Codering
NL00 73780.0 None
GM1680 290.0 None
WK168000 20.0 None
BU16800000 15.0 None
But the same set_index with "inplace=True":
testDataframe = testDataframe.set_index(['Codering'], inplace=True)
print(type(testDataframe))
print(testDataframe.head())
returns
<class 'NoneType'>
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-50-0d6304ebaae1> in <module>()
Version info:
python: 3.4.4.final.0
python-bits: 64
pandas: 0.18.1
numpy: 1.11.1
IPython: 5.2.2
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…