0

I'm python beginner. Those below 'steps_detail' data is like that;

>>> steps_detail
{u'activities-calories': 
    [{u'value': u'1240', u'dateTime': u'2015-04-13'}],
    u'activities-calories-intraday': 
        {u'datasetType': u'minute', u'datasetInterval': 1, u'dataset': 
        [
        {u'mets': 10, u'time': u'00:00:00', u'value': 0.8396000266075134, u'level': 0}, 
        {u'mets': 10, u'time': u'00:01:00', u'value': 0.8396000266075134, u'level': 0}, 
        {u'mets': 10, u'time': u'00:02:00', u'value': 0.8396000266075134, u'level': 0},
        {u'mets': 10, u'time': u'23:58:00', u'value': 0.8396000266075134, u'level': 0}, 
        {u'mets': 10, u'time': u'23:59:00', u'value': 0.8396000266075134, u'level': 0}
         ]      
        }
}

And I want to see this data using DataFrame of pandas like that; because I will using this data to save mysql.

mets time       value              level
10   00:00:00   0.8396000266075134  0 
10   00:01:00   0.8396000266075134  0 
10   00:02:00   0.8396000266075134  0
10   23:58:00   0.8396000266075134  0 
10   23:59:00   0.8396000266075134  0

It's not easy to me, and anyone has some idea? I'm just trying, but some error.

>>>d= DataFrame(steps_detail)
raise ValueError('Mixing dicts with non-Series may lead to 'ValueError: Mixing dicts with non-Series may lead to ambiguous ordering.
1
  • 1
    Could you try read_json Commented Apr 14, 2015 at 17:38

1 Answer 1

1

You can try this

import pandas as pd

pd.DataFrame(steps_detail['activities-calories-intraday']['dataset'])

this will return you the following output

    level  mets      time   value
0      0    10  00:00:00  0.8396
1      0    10  00:01:00  0.8396
2      0    10  00:02:00  0.8396
3      0    10  23:58:00  0.8396
4      0    10  23:59:00  0.8396
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.