I've dataset as in following format :
df = pd.read_csv("data_processing.csv")
df
user_id volume
0 a {"BTCUSDT":1000,"USDTINR":20}
1 b {"BTCINR":30,"USDTINR":10,"ETHINR":15}
2 c {"XRPINR":10,"ETHUSDT":500,"XRPUSDT":200}
3 d {"ETHINR":5}
I want to convert the above dataset in following format :
df
user_id symbol volume
0 a BTCUSDT 1000.0
1 a USDTINR 20.0
2 b USDTINR 10.0
3 b BTCINR 30.0
4 b ETHINR 15.0
5 c XRPINR 10.0
6 c ETHUSDT 500.0
7 c XRPUSDT 200.0
8 d ETHINR 5.0'
What I've tried till now :
Converted string to dict for "volume" column
df['volume'] = df['volume'].map(eval)
converted volume column to from dict to all the keys in one column and all the values in another column
df2 = pd.json_normalize(df['volume']).stack().to_frame(name='volume').reset_index()
But now I'm finding it difficult to map the user_id's to the output of above dataframe.