data_df = pandas.read_csv('details.csv')
data_df = data_df.replace('Null', np.nan)
df = data_df.groupby(['country', 'branch']).count()
df = df.drop('sales', axis=1)
df = df.reset_index()
print df
I would like to convert result of a Data Frame(df) to user defined json format that i mentioned below. After printing the result(df) i will get the result in the form
country branch no_of_employee total_salary count_DOB count_email
x a 30 2500000 20 25
x b 20 350000 15 20
y c 30 4500000 30 30
z d 40 5500000 40 40
z e 10 1000000 10 10
z f 15 1500000 15 15
i would like to convert this to Json.My desired format is
x
{
a
{
no.of employees:30
total salary:2500000
count_email:25
}
b
{
no.of employees:20
total salary:350000
count_email:25
}
}
y
{
c
{
no.of employees:30
total salary:4500000
count_email:30
}
}
z
{
d
{
no.of employees:40
total salary:550000
count_email:40
}
e
{
no.of employees:10
total salary:100000
count_email:15
}
f
{
no.of employees:15
total salary:1500000
count_email:15
}
}
Please notice that i don't want all the fields in the data Frame Result in Json(eg:count_DOB)