1 回答

TA貢獻1812條經(jīng)驗 獲得超5個贊
只是幾點
為了快速讀取文件,請考慮使用不同的格式,如 parquet 或 feather。注意折舊,因此對于長期存儲,csv 就可以了。
pd.concat
是你的朋友。像這樣使用
from pathlib import Path
import pandas as pd
dir_path = r"yourFolderPath"
files_list = [str(p) for p in dir_path.glob("**/*.csv")]
if files_list:
source_dfs = [pd.read_csv(file_) for file_ in files_list]
df = pd.concat(source_dfs, ignore_index=True)
這個 df 然后你可以用來做你的訓(xùn)練。
現(xiàn)在,關(guān)于培訓(xùn)。好吧,這真的取決于一如既往。如果您在這些 csvs 中有日期時間并且它們是連續(xù)的,請繼續(xù)。如果測量之間有中斷,則可能會遇到問題。根據(jù)趨勢、季節(jié)性和噪音,您可以插入缺失數(shù)據(jù)。有多種方法,例如樸素方法、用平均值填充它、根據(jù)之前的值進行預(yù)測等等。沒有對錯之分,這真的取決于你的數(shù)據(jù)是什么樣子的。
編輯:評論不喜歡代碼塊。像這樣工作: 示例:
#df1:
time value
1 1.4
2 2.5
#df2:
time value
3 1.1
4 1.0
#will be glued together to become df = pd.concat([df1, df2], ignore_index=True)
time value
1 1.4
2 2.5
3 1.1
4 1.0
添加回答
舉報