File tree 4 files changed +20
-11
lines changed
4 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,16 @@ Other Enhancements
132
132
Backwards incompatible API changes
133
133
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
134
134
135
+ .. _whatsnew_0210.api_breaking.Period:
136
+
137
+ pd.Period objects are now immutable
138
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
139
+
140
+ :class:`Period` will now raise an ``AttributeError`` when a user tries to
141
+ assign a new value to the `ordinal` or `freq` attributes. This will allow
142
+ for reliable caching which will improve performance in indexing
143
+ operations (:issue:`17116`).
144
+
135
145
.. _whatsnew_0210.api_breaking.pandas_eval:
136
146
137
147
Improved error handling during item assignment in pd.eval
Original file line number Diff line number Diff line change @@ -18,7 +18,6 @@ from pandas import compat
18
18
from pandas.compat import PY2
19
19
20
20
cimport cython
21
- # this is _libs.src.datetime, not python stdlib
22
21
from datetime cimport *
23
22
24
23
cimport util, lib
Original file line number Diff line number Diff line change @@ -1406,3 +1406,13 @@ def test_period_ops_offset(self):
1406
1406
1407
1407
with tm .assert_raises_regex (period .IncompatibleFrequency , msg ):
1408
1408
p - offsets .Hour (2 )
1409
+
1410
+ def test_period_immutable ():
1411
+ # see gh-17116
1412
+ per = pd .Period ('2014Q1' )
1413
+ with pytest .raises (AttributeError , message = "is not writable" ):
1414
+ per .ordinal = 14
1415
+
1416
+ freq = per .freq
1417
+ with pytest .raises (AttributeError , message = "is not writable" ):
1418
+ per .freq = 2 * freq
Original file line number Diff line number Diff line change @@ -248,13 +248,3 @@ def test_empty_like(self):
248
248
expected = np .array ([True ])
249
249
250
250
self ._check_behavior (arr , expected )
251
-
252
-
253
- def test_period_immutable ():
254
- per = pd .Period ('2014Q1' )
255
- with pytest .raises (AttributeError , message = "is not writable" ):
256
- per .ordinal = 14
257
-
258
- freq = per .freq
259
- with pytest .raises (AttributeError , message = "is not writable" ):
260
- per .freq = 2 * freq
You can’t perform that action at this time.
0 commit comments