Quantcast
Channel: How to solve KeyError(f"None of [{key}] are in the [{axis_name}]") in this case (Pandas)? - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by U13-Forward for How to solve KeyError(f"None of [{key}] are in the [{axis_name}]") in this case (Pandas)?

$
0
0

If you want to add new columns you should try reindex with axis=1:

import pandas as pddf = pd.read_csv("sample.csv")final_df = df.reindex(['id','name','grade','address','physics','chemistry','attendance','maths','total'], axis=1)

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>