-
-
Notifications
You must be signed in to change notification settings - Fork 150
type freq
in shift
, consistently use Frequency
alias
#1394
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
base: main
Are you sure you want to change the base?
Changes from all commits
8078382
8e2b00e
83dd9c5
1bfd52a
046e696
7b4194b
6437417
a47ead6
7af641f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,7 +81,6 @@ from pandas._libs.lib import _NoDefaultDoNotUse | |
from pandas._libs.missing import NAType | ||
from pandas._libs.tslibs import BaseOffset | ||
from pandas._libs.tslibs.nattype import NaTType | ||
from pandas._libs.tslibs.offsets import DateOffset | ||
from pandas._typing import ( | ||
S2, | ||
AggFuncTypeBase, | ||
|
@@ -106,6 +105,7 @@ from pandas._typing import ( | |
FillnaOptions, | ||
FloatFormatType, | ||
FormattersType, | ||
Frequency, | ||
GroupByObjectNonScalar, | ||
HashableT, | ||
HashableT1, | ||
|
@@ -135,6 +135,7 @@ from pandas._typing import ( | |
NDFrameT, | ||
NsmallestNlargestKeep, | ||
ParquetEngine, | ||
PeriodFrequency, | ||
QuantileInterpolation, | ||
RandomState, | ||
ReadBuffer, | ||
|
@@ -1683,14 +1684,14 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
) -> Self: ... | ||
def to_timestamp( | ||
self, | ||
freq=..., | ||
freq: PeriodFrequency | None = None, | ||
Comment on lines
1684
to
+1687
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i've always found bizarre that In [4]: pd.Period('2020').to_timestamp('MS')
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[4], line 1
----> 1 pd.Period('2020').to_timestamp('MS')
File ~/scratch/.39venv/lib/python3.9/site-packages/pandas/_libs/tslibs/period.pyx:1868, in pandas._libs.tslibs.period._Period.to_timestamp()
AttributeError: 'pandas._libs.tslibs.offsets.MonthBegin' object has no attribute '_period_dtype_code' (and, on newer versions of pandas): In [2]: pd.Period('2020').to_timestamp('MS')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
File pandas/_libs/tslibs/offsets.pyx:5363, in pandas._libs.tslibs.offsets.to_offset()
File pandas/_libs/tslibs/offsets.pyx:5246, in pandas._libs.tslibs.offsets._validate_to_offset_alias()
ValueError: for Period, please use 'M' instead of 'MS'
The above exception was the direct cause of the following exception:
ValueError Traceback (most recent call last)
Cell In[2], line 1
----> 1 pd.Period('2020').to_timestamp('MS')
File pandas/_libs/tslibs/period.pyx:2041, in pandas._libs.tslibs.period._Period.to_timestamp()
File pandas/_libs/tslibs/period.pyx:1771, in pandas._libs.tslibs.period._Period._maybe_convert_freq()
File pandas/_libs/tslibs/offsets.pyx:5402, in pandas._libs.tslibs.offsets.to_offset()
ValueError: Invalid frequency: MS, failed to parse with error message: ValueError("for Period, please use 'M' instead of 'MS'") but whatever, if that's how it is then it should at least be typed to respect that 🤷 |
||
how: ToTimestampHow = ..., | ||
axis: Axis = 0, | ||
copy: _bool = True, | ||
) -> Self: ... | ||
def to_period( | ||
self, | ||
freq: _str | None = None, | ||
freq: PeriodFrequency | None = None, | ||
axis: Axis = 0, | ||
copy: _bool = True, | ||
) -> Self: ... | ||
|
@@ -2224,7 +2225,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
self, | ||
periods: int = 1, | ||
fill_method: None = None, | ||
freq: DateOffset | dt.timedelta | _str | None = ..., | ||
freq: Frequency | dt.timedelta | None = ..., | ||
Comment on lines
-2227
to
+2228
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the typing here was too tight to begin with
|
||
fill_value: Scalar | NAType | None = ..., | ||
) -> Self: ... | ||
def pop(self, item: _str) -> Series: ... | ||
|
@@ -2341,7 +2342,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
@overload | ||
def rolling( | ||
self, | ||
window: int | str | dt.timedelta | BaseOffset | BaseIndexer, | ||
window: int | Frequency | dt.timedelta | BaseIndexer, | ||
min_periods: int | None = ..., | ||
center: _bool = ..., | ||
on: Hashable | None = ..., | ||
|
@@ -2355,7 +2356,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
@overload | ||
def rolling( | ||
self, | ||
window: int | str | dt.timedelta | BaseOffset | BaseIndexer, | ||
window: int | Frequency | dt.timedelta | BaseIndexer, | ||
min_periods: int | None = ..., | ||
center: _bool = ..., | ||
on: Hashable | None = ..., | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs say
str
but offset objects are also accepted, so I think it's ok to keep the current annotation