0
您好,我已經遍歷多列,它的工作。但在所有的CSV文件中的列名是爲了像這樣:遍歷多列後依次獲取列
Output: id title content tags
但是我的代碼輸出順序列:
Output : content id tags title
我怎麼找回來的順序,所有的該CSV文件作爲
這裏是我下面的代碼:
import glob
import os
import pandas as pd
pd.set_option("display.max_rows", 999)
pd.set_option('max_colwidth',100)
import numpy as np
from IPython.display import display
%matplotlib inline
file_path = 'data/'
all_files = glob.glob(os.path.join(file_path, "*.csv"))
merging_csv_files = (pd.read_csv(f) for f in all_files)
stack_exchange_data = pd.concat(merging_csv_files, ignore_index=True)
print ("Data loaded succesfully!")
print ("Stack Exchane Data has {} rows with {} columns each.".format(*stack_exchange_data.shape))
哇那麼簡單!像魅力一樣工作!謝謝@Ted Petrou –