File tree 2 files changed +14
-0
lines changed
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -289,6 +289,12 @@ def value_counts(self, dropna=False):
289
289
290
290
return value_counts (self ._ndarray , dropna = dropna ).astype ("Int64" )
291
291
292
+ def memory_usage (self , deep = False ):
293
+ result = self ._ndarray .nbytes
294
+ if deep :
295
+ return result + lib .memory_usage_of_objects (self ._ndarray )
296
+ return result
297
+
292
298
# Override parent because we have different return types.
293
299
@classmethod
294
300
def _create_arithmetic_method (cls , op ):
Original file line number Diff line number Diff line change @@ -85,6 +85,14 @@ class TestMethods(base.BaseMethodsTests):
85
85
def test_value_counts (self , all_data , dropna ):
86
86
return super ().test_value_counts (all_data , dropna )
87
87
88
+ def test_memory_usage (self , data ):
89
+ # GH 33963
90
+ series = pd .Series (data , dtype = "string" )
91
+
92
+ assert (
93
+ 0 < series .nbytes <= series .memory_usage () < series .memory_usage (deep = True )
94
+ )
95
+
88
96
89
97
class TestCasting (base .BaseCastingTests ):
90
98
pass
You can’t perform that action at this time.
0 commit comments