Pandas 如何将列表的对象类型读入数据帧?

Pandas 如何将列表的对象类型读入数据帧?,pandas,list,Pandas,List,类型(输出) 名单 打印(输出) 个人资料(username='0000',name='ha',Profile_photo='/pic/Profile_images%2F712711040.jpg',tweets_count=159,follower_count=89,followers_count=34,likes_count=118,is_verified=False,banner_photo='/pic/Profile_banners%2F2582365986%,传记='glority',

类型(输出)

名单

打印(输出)

个人资料(username='0000',name='ha',Profile_photo='/pic/Profile_images%2F712711040.jpg',tweets_count=159,follower_count=89,followers_count=34,likes_count=118,is_verified=False,banner_photo='/pic/Profile_banners%2F2582365986%,传记='glority',用户id=255986,位置='',网站=None)

json.dumps(输出)

TypeError:配置文件类型的对象不可JSON序列化

试试这个:

import pandas as pd
df = pd.DataFrame([profile.__dict__])

with profile是类profile的实例。dumps仅将
str
作为参数。当您使用json.dumps()时,您要求将对象转换为数据帧,但它会将
对象
转换为
字符串
。。看看这个。。