【发布时间】:2018-11-16 13:15:40
【问题描述】:
我有一个 pandas 数据框,它有 8 列需要写入 CSV,它运行良好,但我只想将我的数据框的特定列转换为 csv。如何做到这一点
from pandas import DataFrame
data = DataFrame.from_dict(diction)
data_to_write = data[["channel_id", "channel_img", "desc"]]`
{'data': [{'channel_id': 'UCqTFe5Dz3mpixUrLfMmY6dw', 'title': 'Manoyek',
'channel_img': 'https://yt3.ggpht.com/a-/AN66SAx-
JBOt1_NI6nXTBL2R95kDBaR6Spy9i4_q-g=s240-mo-c-c0xffffffff-rj-k-no', 'desc':
'Jestem Adrian' , 'subscriberCount_gained': 587372, 'subscriberCount_lost':
0}]}
【问题讨论】:
-
字典没有列。你能提供一个minimal reproducible example吗?
标签: python dictionary export-to-csv