![](/img/trans.png)
[英]Comparing multiple columns of two csv files and save output as matching/not matching in new csv file
[英]each two columns in the excel file are separated into multiple csv files
我是python的新手。 我有這個 excel 文件: https : //drive.google.com/file/d/14a37hTH2fv48QdCLlY-5G-3Jzku9MxmZ/view? usp =drivesdk我想將每兩連續列放在一個單獨的 .csv 文件中,提前致謝。
試試這個:
for i in range(df.shape[1]/2):
df[df.columns[2*i:2*i+2]].to_csv(f'data_{i+1}.csv')
加載 excel 文件后,您可以兩個循環
import numpy as np
for i in range(0, number_of_columns, 2):
np.savetxt(str(i) + '.csv', your_data, fmt='%s', delimiter=';') # saving each 2 consecutive columns as 1.csv to e.g. 20.csv
如果您有 DataFrame 並且想使用此解決方案,請使用your_data.to_numpy()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.