0

I was trying to apply group by function and convert the dataframe to json.

df2 = pd.DataFrame(np.array([[11, 'Rondonia', 3,'Alta Floresta'], [11, 'Rondonia', 4,'Cacoal'],[11, 'Rondonia', 5,'Caxibi']]),
                   columns=['uf','nome_uf' ,'municipio', 'nome_municipio'])
df2 

uf  nome_uf municipio   nome_municipio
0   11  Rondonia    3   Alta Floresta
1   11  Rondonia    4   Cacoal
2   11  Rondonia    5   Caxibi
df2.groupby(['uf','nome_uf','municipio','nome_municipio']).count()

uf  nome_uf municipio   nome_municipio
11  Rondonia    3   Alta Floresta
                4   Cacoal
                5   Caxibi

I would like to convert this kind of table with levels to json, keeping the hierarchies. Is it possible?

Pedro Henrique
  • 168
  • 1
  • 2
  • 8

0 Answers0