2 回答

TA貢獻1810條經驗 獲得超5個贊
存儲厘秒的最后一個值并從那里開始計數:
whole_file=['100Hz1-raw.csv','100Hz2-raw.csv','100Hz3-raw.csv','100Hz4-raw.csv','100Hz5-raw.csv','100Hz6-raw.csv']
first_file=True
## create old_centiseconds variable
old_centiseconds = 0
for piece in whole_file:
if not first_file:
skip_row = [0] # if it is not the first csv file then skip the header row (row 0) of that file
else:
skip_row = []
V_raw = pd.read_csv(piece)
# add old_centiseconds onto what you had before
V_raw['centiseconds'] = np.arange(len(V_raw)) + old_centiseconds #label each centisecond
# update old_centiseconds
old_centiseconds += len(V_raw)

TA貢獻1856條經驗 獲得超5個贊
正如我在評論中所說,您可能希望將數據視為一個 numpy 數組,因為這需要更少的內存。您可以通過將 .csv 文件作為 numpy 數組打開然后附加到一個空列表來實現。如果您想將這些 numpy 數組附加在一起,您可以.vstack。下面的代碼應該能夠做到這一點:
from numpy import genfromtxt
whole_file=['100Hz1-raw.csv','100Hz2-raw.csv','100Hz3-raw.csv','100Hz4-raw.csv','100Hz5-raw.csv','100Hz6-raw.csv']
whole_file_numpy_array = []
for file_name in whole_file:
my_data = genfromtxt(file_name, delimiter=',')
whole_file_numpy_array.append(file_name)
combined_numpy_array = np.vstack(whole_file_numpy_array)
添加回答
舉報