How can stacked training rows retain their source month?
pandas.concat combines objects along an axis. Its keys argument can add an index level identifying the source of each block.
concat in practice
January and February can each contain row 7. Month keys distinguish the two. Stacking aligns column names, so a column missing in February leaves missing values to handle.
中文
按月拼接训练数据时,如何追溯来源?
pandas.concat 按轴拼接多个对象,keys 参数能在结果索引上增加一层来源标签。
concat 应用实例
一月和二月都有编号 7,按月份设 keys 后,两条记录可分别定位。按行拼接默认对齐列名,若二月漏列,结果中的空值需要另行处理。