So I was working on a simple python program for fun but got stuck trying to export the data to a CSV file. Right now when running df.to_csv(filename, index=False)
it outputs a CSV file similar to this. I'm using index=False
to avoid having strange columns randomly appearing in the CSV.
Date | a | b | c |
---|---|---|---|
3/31/21 | 3 | Empty | Empty |
3/31/21 | 5 | 4 | Empty |
3/31/21 | Empty | Empty | 3 |
4/1/21 | Empty | Empty | 6 |
4/1/21 | 4 | 3 | 3 |
I'm looking for an output that essentially pushes all the values upwards while still respecting the original date they were in. Something like this would be the ideal output of the previous table.
Date | a | b | c |
---|---|---|---|
3/31/21 | 3 | 4 | 3 |
3/31/21 | 5 | Empty | Empty |
4/1/21 | 4 | 3 | 6 |
4/1/21 | Empty | Empty | 3 |
没有评论:
发表评论