python dataframe转dict
给定dataframer如下:
可以用to_dict()转成dict,转的时候通过指定orient参数来实现不同的方式:
如果想得到cat_nums和avg_length的字典,可以有两种方式:
第一种方式:
第二种方式,把cat_nums变成index,然后使用上述的to_dict()
给定dataframer如下:
可以用to_dict()转成dict,转的时候通过指定orient参数来实现不同的方式:
如果想得到cat_nums和avg_length的字典,可以有两种方式:
第一种方式:
第二种方式,把cat_nums变成index,然后使用上述的to_dict()