So if I have a dataframe like such:
A B C
1 1 1
2 2 2
3 3 3
I want to achieve this:
A B C
1 1 1
1 1 1
1 1 1
1 1 1
2 2 2
2 2 2
2 2 2
2 2 2
3 3 3
3 3 3
3 3 3
3 3 3
3 3 3
I know that this will probably involve ffill and the general process as describes in my question, but if there is a simpler way to do this, I'm perfectly happy with that. I just want the quickest and easiest way, because my script will be repeating this many times.
Thanks for all the help!
I think this is repeat
not ffill
df.reindex(df.index.repeat(4))
Out[63]:
A B C
0 1 1 1
0 1 1 1
0 1 1 1
0 1 1 1
1 2 2 2
1 2 2 2
1 2 2 2
1 2 2 2
2 3 3 3
2 3 3 3
2 3 3 3
2 3 3 3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.