@@ -36,6 +36,7 @@ class ExtensionArray(object):
36
36
* isna
37
37
* take
38
38
* copy
39
+ * append
39
40
* _concat_same_type
40
41
41
42
An additional method is available to satisfy pandas' internal,
@@ -49,6 +50,7 @@ class ExtensionArray(object):
49
50
methods:
50
51
51
52
* fillna
53
+ * dropna
52
54
* unique
53
55
* factorize / _values_for_factorize
54
56
* argsort / _values_for_argsort
@@ -82,14 +84,16 @@ class ExtensionArray(object):
82
84
# Constructors
83
85
# ------------------------------------------------------------------------
84
86
@classmethod
85
- def _from_sequence (cls , scalars ):
87
+ def _from_sequence (cls , scalars , copy = False ):
86
88
"""Construct a new ExtensionArray from a sequence of scalars.
87
89
88
90
Parameters
89
91
----------
90
92
scalars : Sequence
91
93
Each element will be an instance of the scalar type for this
92
94
array, ``cls.dtype.type``.
95
+ copy : boolean, default True
96
+ if True, copy the underlying data
93
97
Returns
94
98
-------
95
99
ExtensionArray
@@ -379,6 +383,16 @@ def fillna(self, value=None, method=None, limit=None):
379
383
new_values = self .copy ()
380
384
return new_values
381
385
386
+ def dropna (self ):
387
+ """ Return ExtensionArray without NA values
388
+
389
+ Returns
390
+ -------
391
+ valid : ExtensionArray
392
+ """
393
+
394
+ return self [~ self .isna ()]
395
+
382
396
def unique (self ):
383
397
"""Compute the ExtensionArray of unique values.
384
398
@@ -567,6 +581,34 @@ def copy(self, deep=False):
567
581
"""
568
582
raise AbstractMethodError (self )
569
583
584
+ def append (self , other ):
585
+ """
586
+ Append a collection of Arrays together
587
+
588
+ Parameters
589
+ ----------
590
+ other : ExtenionArray or list/tuple of ExtenionArrays
591
+
592
+ Returns
593
+ -------
594
+ appended : ExtensionArray
595
+ """
596
+
597
+ to_concat = [self ]
598
+ cls = self .__class__
599
+
600
+ if isinstance (other , (list , tuple )):
601
+ to_concat = to_concat + list (other )
602
+ else :
603
+ to_concat .append (other )
604
+
605
+ for obj in to_concat :
606
+ if not isinstance (obj , cls ):
607
+ raise TypeError ('all inputs must be of type {}' .format (
608
+ cls .__name__ ))
609
+
610
+ return cls ._concat_same_type (to_concat )
611
+
570
612
# ------------------------------------------------------------------------
571
613
# Block-related methods
572
614
# ------------------------------------------------------------------------
0 commit comments