I have a dataframe below:
import pandas as pd
df = pd.DataFrame({"Name":["Jack","Joe","Al","Al","Joe","Jack","Jack"],"X1":[1,4,6,5,7,9,2]})
I made a different dataframe for each value in the "Name" column.
dic = {}
k=1
for i in set(df.Name):
dic[k] = df.loc[df.Name == i]
dic[k].reset_index(inplace=True)
dic[k].drop(columns="index",inplace = True)
k += 1
Now keys are "Jack","Joe" and "Al", values are dataframes.
But keys order change every time when I run the code. Is there any way to fix key order?