user8270077
user8270077

Reputation: 5071

Reindex in Pandas is not accepting axis argument?

I am running the examples in the pandas documentation (https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.reindex.html) and I got an unexpected exception:

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"

Upvotes: 3

Views: 4722

Answers (1)

jezrael
jezrael

Reputation: 862801

It is pandas under 0.21.0 problem, so use general solution:

df = df.reindex(columns=['http_status', 'user_agent'])

Upvotes: 5

Related Questions