I have a CSV file for example like this :
id | name | physics | chemistry | maths | |
---|---|---|---|---|---|
1 | Sta | [email protected] | 67 | 78 | 90 |
2 | Danny | [email protected] | 77 | 98 | 89 |
3 | Elle | [email protected] | 77 | 67 | 90 |
Now I want to output a new CSV file using pandas which has new columns too for example like this :
id | name | grade | address | physics | chemistry | attendance | maths | total |
---|
I want to create new columns in random places and I want to place the value as blank in the new columns.
I have tried using :
import pandas as pd
df = pd.read_csv("sample.csv")
final_df = df.loc[['id','name','grade','address','physics','chemistry','attendance','maths','total']]
When I did this I got an error :
KeyError(f“None of [{key}] are in the [{axis_name}]”)
Any ideas or suggestions to arrange this.