mirror of
https://github.com/elastic/eland.git
synced 2025-07-11 00:02:14 +08:00
Add DataFrame.size and Series.size
This commit is contained in:
parent
d50e06dda5
commit
6c2f9a2ed2
@ -338,7 +338,7 @@ script instead of being modified manually.
|
|||||||
+---------------------------------------+------------+
|
+---------------------------------------+------------+
|
||||||
| ``ed.DataFrame.shift()`` | No |
|
| ``ed.DataFrame.shift()`` | No |
|
||||||
+---------------------------------------+------------+
|
+---------------------------------------+------------+
|
||||||
| ``ed.DataFrame.size`` | No |
|
| ``ed.DataFrame.size`` | **Yes** |
|
||||||
+---------------------------------------+------------+
|
+---------------------------------------+------------+
|
||||||
| ``ed.DataFrame.skew()`` | No |
|
| ``ed.DataFrame.skew()`` | No |
|
||||||
+---------------------------------------+------------+
|
+---------------------------------------+------------+
|
||||||
@ -910,7 +910,7 @@ script instead of being modified manually.
|
|||||||
+---------------------------------------+------------+
|
+---------------------------------------+------------+
|
||||||
| ``ed.Series.shift()`` | No |
|
| ``ed.Series.shift()`` | No |
|
||||||
+---------------------------------------+------------+
|
+---------------------------------------+------------+
|
||||||
| ``ed.Series.size`` | No |
|
| ``ed.Series.size`` | **Yes** |
|
||||||
+---------------------------------------+------------+
|
+---------------------------------------+------------+
|
||||||
| ``ed.Series.skew()`` | No |
|
| ``ed.Series.skew()`` | No |
|
||||||
+---------------------------------------+------------+
|
+---------------------------------------+------------+
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
from typing import Tuple
|
||||||
|
|
||||||
from eland.query_compiler import QueryCompiler
|
from eland.query_compiler import QueryCompiler
|
||||||
|
|
||||||
@ -505,3 +506,28 @@ class NDFrame(ABC):
|
|||||||
@abstractmethod
|
@abstractmethod
|
||||||
def sample(self, n=None, frac=None, random_state=None):
|
def sample(self, n=None, frac=None, random_state=None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@property
|
||||||
|
def shape(self) -> Tuple[int, ...]:
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@property
|
||||||
|
def size(self) -> int:
|
||||||
|
"""
|
||||||
|
Return an int representing the number of elements in this object.
|
||||||
|
|
||||||
|
Return the number of rows if Series. Otherwise return the number of rows times number of columns if DataFrame.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
int:
|
||||||
|
Number of elements in the object
|
||||||
|
|
||||||
|
See Also
|
||||||
|
--------
|
||||||
|
:pandas_api_docs:`pandas.DataFrame.size`
|
||||||
|
"""
|
||||||
|
product = 0
|
||||||
|
for dim in self.shape:
|
||||||
|
product = (product or 1) * dim
|
||||||
|
return product
|
||||||
|
@ -38,3 +38,10 @@ class TestDataFrameShape(TestData):
|
|||||||
ed_shape = ed_flights.shape
|
ed_shape = ed_flights.shape
|
||||||
|
|
||||||
assert pd_shape == ed_shape
|
assert pd_shape == ed_shape
|
||||||
|
|
||||||
|
def test_size(self):
|
||||||
|
pd_flights = self.pd_flights()
|
||||||
|
ed_flights = self.ed_flights()
|
||||||
|
|
||||||
|
assert pd_flights.size == ed_flights.size
|
||||||
|
assert pd_flights.FlightDelayMin.size == ed_flights.FlightDelayMin.size
|
||||||
|
Loading…
x
Reference in New Issue
Block a user