Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有下面的代码,它为我各自的每个数据框附加了一个年份列。我认为这将使用 for 循环,但由于每年的年份不同,我不确定该怎么做。
hic_dfs = [hic15,hic16,hic17,hic18,hic19] hic15['year']=2015 hic16['year']=2016 hic17['year']=2017 hic18['year']=2018 hic19['year']=2019
提前致谢!
尝试这个:
ye = 2015 for idx, elem in enumerate(hic_dfs): elem["year"] = ye + idx