1 回答

TA贡献1812条经验 获得超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 然后你可以用来做你的训练。
现在,关于培训。好吧,这真的取决于一如既往。如果您在这些 csvs 中有日期时间并且它们是连续的,请继续。如果测量之间有中断,则可能会遇到问题。根据趋势、季节性和噪音,您可以插入缺失数据。有多种方法,例如朴素方法、用平均值填充它、根据之前的值进行预测等等。没有对错之分,这真的取决于你的数据是什么样子的。
编辑:评论不喜欢代码块。像这样工作: 示例:
#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
添加回答
举报