我已经让这个脚本在另一个堆栈溢出帖子的基础上工作,我已经非常接近让它做我想让它做的事情。最后一步是让新的csv保存在我作为参数添加的第二个位置。在这个代码中我想替换“删除.csv“有目的地,但没用。它把它保存在源代码所在的地方,我想告诉它保存在哪里。有谁能帮我指出正确的方向吗?非常感谢!在
#!/usr/bin/python
import sys
import pandas as pd
filename = sys.argv[1]
destination = sys.argv[2]
df = pd.read_csv(filename)
keep_cols = ["Path", "IPTC - Title", "Description", "Person(s) of Import", "Museum Location", "Catalog Name", "Catalog Number", "Catalog Link", "Keywords", "Special Exhibitions", "Donor Credit", "Video Licensing", "Image Licensing", "Music Licensing", "Audio Licensing", "Relate Assets", "IPTC - Creator", "IPTC - City", "IPTC - Country", "Rights Usage Terms"]
new_df = df[keep_cols]
new_df.to_csv("removed.csv", index=False)
你可以设定确切的路径。在
如:
或者像这样:
^{pr2}$注意:您还可以通过只在需要la的列中输入来提高性能:
^{3}$相关问题 更多 >
编程相关推荐