score:23

Accepted answer

Transform your date index back into a simple data column with reset_index, and then generate your json object by using the orient='index' property:

In [11]: aggregated_df.reset_index().to_json(orient='index')
Out[11]: '{"0":{"created":"05-16-13","counter":3},"1":{"created":"05-17-13","counter":1},"2":{"created":"05-18-13","counter":1}}'

Related Query

More Query from same tag