2

I am looping through the days of the week and grabbing data from a database in 15 minute intervals. Every time I loop through a day, I am grabbing the appropriate data and placing in a Dataframe using pd.concat. I am using Pandas to do this.

Every time I go to the next day, however, it seems that the data doesn't get added to the intended position. For example, this is what the dataframe looks like:

    1   2   3   1   2   3   1   2   3
1   x   x   x
2   x   x   x
3   x   x   x
4               x   x   x
5               x   x   x
6               x   x   x
7                           x   x   x
8                           x   x   x
9                           x   x   x

Instead of what it should look like:

    1   2   3
1   x   x   x
2   x   x   x
3   x   x   x
4   x   x   x
5   x   x   x
6   x   x   x
7   x   x   x
8   x   x   x
9   x   x   x

Each 'block' of data represents a day, and I would like them stacked on top of each other rather than offset by the previous day.

When I print the dataframes to my console, it seems that the empty cells to the left of the data are NaN, but when I tried to remove those NaN values, nothing changed.

I would love any input, or if you need more information to provide a helpful answer let me know and I can try to add it. Thanks.

1 Answers1

4

IIUC you want to use:

pd.concat(..., ignore_index=True)
#              ^^^^^^^^^^^^^^^^^
MaxU - stand with Ukraine
  • 205,989
  • 36
  • 386
  • 419