Skip to content

Commit 8ffd150

Browse files
ueshinHyukjinKwon
authored andcommitted
[SPARK-55293][PS][TESTS][FOLLOW-UP] Avoid more old offset aliases
### What changes were proposed in this pull request? This is a follow-up of #54077. Avoids more old offset aliases. ### Why are the changes needed? There are still some places using the old offset aliases. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Fixed the related tests. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #54095 from ueshin/issues/SPARK-55293/ye. Authored-by: Takuya Ueshin <[email protected]> Signed-off-by: Hyukjin Kwon <[email protected]>
1 parent 30ace9f commit 8ffd150

File tree

8 files changed

+17
-17
lines changed

8 files changed

+17
-17
lines changed

python/pyspark/pandas/datetimes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ def is_leap_year(self) -> "ps.Series":
517517
This method is available on Series with datetime values under
518518
the ``.dt`` accessor.
519519
520-
>>> dates_series = ps.Series(pd.date_range("2012-01-01", "2015-01-01", freq="Y"))
520+
>>> dates_series = ps.Series(pd.date_range("2012-01-01", "2015-01-01", freq="YE"))
521521
>>> dates_series
522522
0 2012-12-31
523523
1 2013-12-31
@@ -700,7 +700,7 @@ def round(self, freq: Union[str, DateOffset], *args: Any, **kwargs: Any) -> "ps.
700700
2 2018-01-01 12:01:00
701701
dtype: datetime64[ns]
702702
703-
>>> series.dt.round("H")
703+
>>> series.dt.round("h")
704704
0 2018-01-01 12:00:00
705705
1 2018-01-01 12:00:00
706706
2 2018-01-01 12:00:00
@@ -755,7 +755,7 @@ def floor(self, freq: Union[str, DateOffset], *args: Any, **kwargs: Any) -> "ps.
755755
2 2018-01-01 12:01:00
756756
dtype: datetime64[ns]
757757
758-
>>> series.dt.floor("H")
758+
>>> series.dt.floor("h")
759759
0 2018-01-01 11:00:00
760760
1 2018-01-01 12:00:00
761761
2 2018-01-01 12:00:00
@@ -810,7 +810,7 @@ def ceil(self, freq: Union[str, DateOffset], *args: Any, **kwargs: Any) -> "ps.S
810810
2 2018-01-01 12:01:00
811811
dtype: datetime64[ns]
812812
813-
>>> series.dt.ceil("H")
813+
>>> series.dt.ceil("h")
814814
0 2018-01-01 12:00:00
815815
1 2018-01-01 12:00:00
816816
2 2018-01-01 13:00:00

python/pyspark/pandas/indexes/datetimes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def is_leap_year(self) -> Index:
505505
506506
Examples
507507
--------
508-
>>> idx = ps.date_range("2012-01-01", "2015-01-01", freq="Y") # doctest: +SKIP
508+
>>> idx = ps.date_range("2012-01-01", "2015-01-01", freq="YE") # doctest: +SKIP
509509
>>> idx.is_leap_year # doctest: +SKIP
510510
Index([True, False, False], dtype='bool')
511511
"""

python/pyspark/pandas/namespace.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,7 +1879,7 @@ def date_range(
18791879
18801880
Multiples are allowed
18811881
1882-
>>> ps.date_range(start='1/1/2018', periods=5, freq='3M') # doctest: +SKIP
1882+
>>> ps.date_range(start='1/1/2018', periods=5, freq='3ME') # doctest: +SKIP
18831883
DatetimeIndex(['2018-01-31', '2018-04-30', '2018-07-31', '2018-10-31',
18841884
'2019-01-31'],
18851885
dtype='datetime64[ns]', freq=None)
@@ -2087,7 +2087,7 @@ def timedelta_range(
20872087
The freq parameter specifies the frequency of the TimedeltaIndex.
20882088
Only fixed frequencies can be passed, non-fixed frequencies such as ‘M’ (month end) will raise.
20892089
2090-
>>> ps.timedelta_range(start='1 day', end='2 days', freq='6H')
2090+
>>> ps.timedelta_range(start='1 day', end='2 days', freq='6h')
20912091
... # doctest: +NORMALIZE_WHITESPACE
20922092
TimedeltaIndex(['1 days 00:00:00', '1 days 06:00:00', '1 days 12:00:00',
20932093
'1 days 18:00:00', '2 days 00:00:00'],

python/pyspark/pandas/resample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def _downsample(self, f: str) -> DataFrame:
324324
# ]
325325
# index = pd.DatetimeIndex(dates)
326326
# pdf = pd.DataFrame(np.array([1,2,3]), index=index, columns=['A'])
327-
# pdf.resample('3Y').max()
327+
# pdf.resample('3YE').max()
328328
# A
329329
# 2012-12-31 2.0
330330
# 2015-12-31 NaN

python/pyspark/pandas/series.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7223,7 +7223,7 @@ def resample(
72237223
Downsample the series into 3 minute bins and sum the values
72247224
of the timestamps falling into a bin.
72257225
7226-
>>> series.resample('3T').sum().sort_index()
7226+
>>> series.resample('3min').sum().sort_index()
72277227
2000-01-01 00:00:00 3.0
72287228
2000-01-01 00:03:00 12.0
72297229
2000-01-01 00:06:00 21.0
@@ -7239,7 +7239,7 @@ def resample(
72397239
To include this value, close the right side of the bin interval as
72407240
illustrated in the example below this one.
72417241
7242-
>>> series.resample('3T', label='right').sum().sort_index()
7242+
>>> series.resample('3min', label='right').sum().sort_index()
72437243
2000-01-01 00:03:00 3.0
72447244
2000-01-01 00:06:00 12.0
72457245
2000-01-01 00:09:00 21.0
@@ -7248,7 +7248,7 @@ def resample(
72487248
Downsample the series into 3 minute bins as above, but close the right
72497249
side of the bin interval.
72507250
7251-
>>> series.resample('3T', label='right', closed='right').sum().sort_index()
7251+
>>> series.resample('3min', label='right', closed='right').sum().sort_index()
72527252
2000-01-01 00:00:00 0.0
72537253
2000-01-01 00:03:00 6.0
72547254
2000-01-01 00:06:00 15.0
@@ -7257,7 +7257,7 @@ def resample(
72577257
72587258
Upsample the series into 30 second bins.
72597259
7260-
>>> series.resample('30S').sum().sort_index()[0:5] # Select first 5 rows
7260+
>>> series.resample('30s').sum().sort_index()[0:5] # Select first 5 rows
72617261
2000-01-01 00:00:00 0.0
72627262
2000-01-01 00:00:30 0.0
72637263
2000-01-01 00:01:00 1.0

python/pyspark/pandas/tests/resample/test_error.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ def test_resample_error(self):
3131
with self.assertRaisesRegex(
3232
NotImplementedError, "resample currently works only for DatetimeIndex"
3333
):
34-
psdf.resample("3Y").sum()
34+
psdf.resample("3YE").sum()
3535

3636
with self.assertRaisesRegex(
3737
NotImplementedError, "resample currently works only for DatetimeIndex"
3838
):
39-
psdf.id.resample("3Y").sum()
39+
psdf.id.resample("3YE").sum()
4040

4141
dates = [
4242
datetime.datetime(2012, 1, 2),

python/pyspark/pandas/tests/resample/test_frame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ def test_dataframe_resample(self):
132132
self._test_resample(self.pdf6, self.psdf6, ["29s", "10min", "3h"], "left", "right", "var")
133133

134134
with self.assertRaisesRegex(ValueError, "rule code YE-DEC is not supported"):
135-
self._test_resample(self.pdf2, self.psdf2, ["3A", "11ME", "D"], None, "left", "max")
135+
self._test_resample(self.pdf2, self.psdf2, ["3YE", "11ME", "D"], None, "left", "max")
136136
with self.assertRaisesRegex(ValueError, "rule code YE-DEC is not supported"):
137-
self._test_resample(self.pdf1, self.psdf1, ["3Y", "9ME", "17D"], None, None, "min")
137+
self._test_resample(self.pdf1, self.psdf1, ["3YE", "9ME", "17D"], None, None, "min")
138138

139139

140140
class ResampleFrameTests(ResampleFrameMixin, PandasOnSparkTestCase, TestUtils):

python/pyspark/pandas/tests/resample/test_series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def test_series_resample(self):
133133
self._test_resample(self.pdf6.A, self.psdf6.A, ["111s"], "right", "right", "std")
134134

135135
with self.assertRaisesRegex(ValueError, "rule code YE-DEC is not supported"):
136-
self._test_resample(self.pdf1.A, self.psdf1.A, ["4Y"], "right", None, "min")
136+
self._test_resample(self.pdf1.A, self.psdf1.A, ["4YE"], "right", None, "min")
137137

138138

139139
class ResampleSeriesTests(ResampleSeriesMixin, PandasOnSparkTestCase, TestUtils):

0 commit comments

Comments
 (0)