我有这个数据框,我想每周重复一次,直到下周才重复
输入
Week Netflix: (Worldwide)
2012-12-02 50
2012-12-09 51
输出
Week Netflix: (Worldwide)
2012-12-02 50
2012-12-03 50
2012-12-04 50
2012-12-05 50
2012-12-06 50
2012-12-07 50
2012-12-08 50
2012-12-09 51
答案 0 :(得分:6)
使用resample():
x is _not_ an instance of some abstract class that extends Parent?
来自@Wen的替代解决方案:
In [129]: df.set_index('Week').resample('1D').ffill().reset_index()
Out[129]:
Week Netflix: (Worldwide)
0 2012-12-02 50
1 2012-12-03 50
2 2012-12-04 50
3 2012-12-05 50
4 2012-12-06 50
5 2012-12-07 50
6 2012-12-08 50
7 2012-12-09 51