pandas方法中的列列表

时间:2014-08-22 07:41:47

标签: python pandas

我无法提供要在csv文件中返回的列列表。

trans.to_csv('study10.csv' , encoding='utf-8', columns = [("reg_no", "st_name", "c_six_to_ten", "values")] )

KeyError: "[[('reg_no', 'st_name', 'c_six_to_ten', 'values')]] are not in ALL in the [columns]"

如何选择要保存到csv文件的列?

1 个答案:

答案 0 :(得分:1)

应该是:

trans.to_csv('study10.csv' , encoding='utf-8', columns = ["reg_no", "st_name", "c_six_to_ten", "values"] )

你尝试的是一个包含单个元组的列表