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 Answer 1

3

IIUC you want to use:

pd.concat(..., ignore_index=True)
#              ^^^^^^^^^^^^^^^^^
Sign up to request clarification or add additional context in comments.

4 Comments

thanks for the input, i tried that but it unfortunately didn't work. what does ignore_index do that should fix the issue?
@VinodKrishnamurthy, can you post two small reproducible data sets (in CSV/text form) and your desired data set so we could reproduce your issue?
sure, but do you think you could clarify what exactly you are asking for?
@VinodKrishnamurthy, i'm asking for data sets which would help to reproduce the issue. Please read how to make good reproducible pandas examples

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.