-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
datetime index list when pd.concat does not infer frequency #12231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
maybe related to #12195 |
Hi @dacoex can you provide an example that shows your problem? For example In [2]: idx1 = pd.period_range('2015-01-01', freq='10T', periods=10)
In [3]: idx2 = pd.period_range('2015-02-01', freq='10T', periods=10)
In [4]: pd.concat([pd.Series(1, index=idx1), pd.Series(2, index=idx2)])
Out[4]:
2015-01-01 00:00 1
2015-01-01 00:10 1
2015-01-01 00:20 1
2015-01-01 00:30 1
2015-01-01 00:40 1
..
2015-02-01 00:50 2
2015-02-01 01:00 2
2015-02-01 01:10 2
2015-02-01 01:20 2
2015-02-01 01:30 2
Freq: 10T, dtype: int64
In [5]: pd.concat([pd.Series(1, index=idx1), pd.Series(2, index=idx2)]).index
Out[5]:
PeriodIndex(['2015-01-01 00:00', '2015-01-01 00:10', '2015-01-01 00:20',
'2015-01-01 00:30', '2015-01-01 00:40', '2015-01-01 00:50',
'2015-01-01 01:00', '2015-01-01 01:10', '2015-01-01 01:20',
'2015-01-01 01:30', '2015-02-01 00:00', '2015-02-01 00:10',
'2015-02-01 00:20', '2015-02-01 00:30', '2015-02-01 00:40',
'2015-02-01 00:50', '2015-02-01 01:00', '2015-02-01 01:10',
'2015-02-01 01:20', '2015-02-01 01:30'],
dtype='int64', freq='10T') is correct. Also post your pandas version, as you noted it might have been fixed in #12195 |
|
@jreback thanks for the clarification. In my case, I have concatenated 2 df with the same frequency which was assigned before. The frames were generated by a loop and added to a list of frames.
But not the combined frame:
Astonishingly, in the following simple example, it works:
How could I debug this issue further? |
I forgot:
|
no idea, you will simply have to step thru your code and examine each step. |
The cookbook Data In/Out points to: how to read in multiple files, appending to create a single dataframe.
When using the suggested procedure on 2 df with freq '10T' the index is without the freq after the concat.
The text was updated successfully, but these errors were encountered: