Skip to content

Conversation

@jaheba
Copy link

@jaheba jaheba commented Jul 6, 2022

  • closes #xxxx (Replace xxxx with the Github issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

@jaheba
Copy link
Author

jaheba commented Jul 6, 2022

Something that threw me off:

In [30]: p = pd.Period("2020-01-01", "2d")

In [31]: p.asfreq(p.freq)
Out[31]: Period('2020-01-02', '2D')

Since the default for how of .asfreq is end, this means that using .asfreq is not a no-op when using multiple frequencies.

@jaheba
Copy link
Author

jaheba commented Jul 6, 2022

In other words, I find the behaviour insane and inconsistent:

In [2]: import pandas as pd

In [3]: dr = pd.date_range("2020", freq="2d", periods=3)

In [4]: dr.to_series().asfreq("2d")
Out[4]: 
2020-01-01   2020-01-01
2020-01-03   2020-01-03
2020-01-05   2020-01-05
Freq: 2D, dtype: datetime64[ns]

In [5]: dr.to_period().to_series().asfreq("2d")
Out[5]: 
2020-01-02    2020-01-01
2020-01-04    2020-01-03
2020-01-06    2020-01-05
Freq: 2D, dtype: period[2D]

I have to say the experience using Period is very bad and frustrating.

@mroeschke mroeschke added Frequency DateOffsets Period Period data type labels Jul 22, 2022
@github-actions
Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Aug 22, 2022
@mroeschke
Copy link
Member

Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen.

@mroeschke mroeschke closed this Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frequency DateOffsets Period Period data type Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants