Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas
- import json
- frame = pandas.DataFrame([{'one':1.0,'two':2.0},{'one':float('nan'),'two':3.0}])
- # >>> frame
- # one two
- # 0 1.0 2.0
- # 1 NaN 3.0
- # >>> frame.T.to_dict().values()
- # [{'two': 2.0, 'one': 1.0}, {'two': 3.0, 'one': nan}]
- json_frame = json.dumps( frame.T.to_dict().values() )
- # >>> json_frame
- # '[{"two": 2.0, "one": 1.0}, {"two": 3.0, "one": NaN}]'
- json_frame = '[{"two": 2.0, "one": 1.0}, {"two": 3.0, "one": NaN}]'
- // "[{"two": 2.0, "one": 1.0}, {"two": 3.0, "one": NaN}]"
- JSON.parse(json_frame)
- // SyntaxError: Unexpected token N(…)
- frame.where((pandas.notnull(frame)), None)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement