[英]Select the specific column from csv and update the another csv
我有一个目录,其中包含许多带有 .csv 文件的文件夹,我需要从所有 .csv 中选择一个特定的列并附加到另一个 result.csv
You should read all csv files one by one with os library and read/keep the specific column that you want, like this您应该使用 os 库一一读取所有 csv 文件并读取/保留所需的特定列,如下所示
csv_file = pd.read_csv("csv_name_from_os.csv")
column_val_list = csv_file.specific_column_name._ndarray_values
then you can concat multiple columns with然后你可以连接多个列
result = pd.concat([result, dat2], axis=1)
at the end you should save the frame as csv file.最后,您应该将框架保存为 csv 文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.