@@ -216,14 +216,6 @@ def _from_sequence(cls, scalars, dtype=None, copy=False):
216
216
ordinals = libperiod .extract_ordinals (periods , freq )
217
217
return cls (ordinals , freq = freq )
218
218
219
- def _values_for_factorize (self ):
220
- return self .asi8 , iNaT
221
-
222
- @classmethod
223
- def _from_factorized (cls , values , original ):
224
- # type: (Sequence[Optional[Period]], PeriodArray) -> PeriodArray
225
- return cls (values , freq = original .freq )
226
-
227
219
@classmethod
228
220
def _from_datetime64 (cls , data , freq , tz = None ):
229
221
"""Construct a PeriodArray from a datetime64 array
@@ -262,14 +254,6 @@ def _generate_range(cls, start, end, periods, freq, fields):
262
254
263
255
return subarr , freq
264
256
265
- @classmethod
266
- def _concat_same_type (cls , to_concat ):
267
- freq = {x .freq for x in to_concat }
268
- assert len (freq ) == 1
269
- freq = list (freq )[0 ]
270
- values = np .concatenate ([x ._data for x in to_concat ])
271
- return cls (values , freq = freq )
272
-
273
257
# --------------------------------------------------------------------
274
258
# Data / Attributes
275
259
@@ -415,29 +399,20 @@ def __setitem__(
415
399
raise TypeError (msg )
416
400
self ._data [key ] = value
417
401
418
- def take (self , indices , allow_fill = False , fill_value = None ):
419
- if allow_fill :
420
- if isna (fill_value ):
421
- fill_value = iNaT
422
- elif isinstance (fill_value , Period ):
423
- if self .freq != fill_value .freq :
424
- msg = DIFFERENT_FREQ_INDEX .format (
425
- self .freq .freqstr ,
426
- fill_value .freqstr
427
- )
428
- raise IncompatibleFrequency (msg )
429
-
430
- fill_value = fill_value .ordinal
431
- else :
432
- msg = "'fill_value' should be a Period. Got '{}'."
433
- raise ValueError (msg .format (fill_value ))
434
-
435
- new_values = algos .take (self ._data ,
436
- indices ,
437
- allow_fill = allow_fill ,
438
- fill_value = fill_value )
439
-
440
- return type (self )(new_values , self .freq )
402
+ @Appender (dtl .DatetimeLikeArrayMixin ._validate_fill_value .__doc__ )
403
+ def _validate_fill_value (self , fill_value ):
404
+ if isna (fill_value ):
405
+ fill_value = iNaT
406
+ elif isinstance (fill_value , Period ):
407
+ if fill_value .freq != self .freq :
408
+ msg = DIFFERENT_FREQ_INDEX .format (self .freq .freqstr ,
409
+ fill_value .freqstr )
410
+ raise IncompatibleFrequency (msg )
411
+ fill_value = fill_value .ordinal
412
+ else :
413
+ raise ValueError ("'fill_value' should be a Period. "
414
+ "Got '{got}'." .format (got = fill_value ))
415
+ return fill_value
441
416
442
417
def fillna (self , value = None , method = None , limit = None ):
443
418
# TODO(#20300)
@@ -474,9 +449,6 @@ def fillna(self, value=None, method=None, limit=None):
474
449
new_values = self .copy ()
475
450
return new_values
476
451
477
- def copy (self , deep = False ):
478
- return type (self )(self ._data .copy (), freq = self .freq )
479
-
480
452
def value_counts (self , dropna = False ):
481
453
from pandas import Series , PeriodIndex
482
454
0 commit comments