Pandas 中的重新索引不接受轴参数?
Reindex in Pandas is not accepting axis argument?
我是 运行 pandas 文档中的示例 (https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.reindex.html)
我遇到了意外异常:
index = ['Firefox', 'Chrome', 'Safari', 'IE10', 'Konqueror']
df = pd.DataFrame({
'http_status': [200,200,404,404,301],
'response_time': [0.04, 0.02, 0.07, 0.08, 1.0]},
index=index)
df.reindex(['http_status', 'user_agent'], axis="columns")
TypeError: reindex() got an unexpected keyword argument "axis"
是pandas under 0.21.0 problem,所以用通解:
df = df.reindex(columns=['http_status', 'user_agent'])
我是 运行 pandas 文档中的示例 (https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.reindex.html) 我遇到了意外异常:
index = ['Firefox', 'Chrome', 'Safari', 'IE10', 'Konqueror']
df = pd.DataFrame({
'http_status': [200,200,404,404,301],
'response_time': [0.04, 0.02, 0.07, 0.08, 1.0]},
index=index)
df.reindex(['http_status', 'user_agent'], axis="columns")
TypeError: reindex() got an unexpected keyword argument "axis"
是pandas under 0.21.0 problem,所以用通解:
df = df.reindex(columns=['http_status', 'user_agent'])