Skip to content

Commit c0efec8

Browse files
feat: add aliases for several series properties (#80)
* feat: add aliases for several series properties --------- Co-authored-by: Tim Swast <[email protected]>
1 parent bd692d8 commit c0efec8

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

bigframes/series.py

+15
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ def shape(self) -> typing.Tuple[int]:
9999
def size(self) -> int:
100100
return self.shape[0]
101101

102+
@property
103+
def ndim(self) -> int:
104+
return 1
105+
102106
@property
103107
def empty(self) -> bool:
104108
return self.shape[0] == 0
@@ -123,6 +127,13 @@ def query_job(self) -> Optional[bigquery.QueryJob]:
123127
def struct(self) -> structs.StructAccessor:
124128
return structs.StructAccessor(self._block)
125129

130+
@property
131+
def T(self) -> Series:
132+
return self.transpose()
133+
134+
def transpose(self) -> Series:
135+
return self
136+
126137
def _set_internal_query_job(self, query_job: bigquery.QueryJob):
127138
self._query_job = query_job
128139

@@ -362,6 +373,8 @@ def ffill(self, *, limit: typing.Optional[int] = None) -> Series:
362373
window = bigframes.core.WindowSpec(preceding=limit, following=0)
363374
return self._apply_window_op(agg_ops.LastNonNullOp(), window)
364375

376+
pad = ffill
377+
365378
def bfill(self, *, limit: typing.Optional[int] = None) -> Series:
366379
window = bigframes.core.WindowSpec(preceding=0, following=limit)
367380
return self._apply_window_op(agg_ops.FirstNonNullOp(), window)
@@ -743,6 +756,8 @@ def agg(self, func: str | typing.Sequence[str]) -> scalars.Scalar | Series:
743756
agg_ops.lookup_agg_func(typing.cast(str, func))
744757
)
745758

759+
aggregate = agg
760+
746761
def skew(self):
747762
count = self.count()
748763
if count < 3:

third_party/bigframes_vendored/pandas/core/series.py

+14
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@ def name(self) -> Hashable:
6464
"""
6565
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
6666

67+
@property
68+
def T(self) -> Series:
69+
"""Return the transpose, which is by definition self."""
70+
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
71+
72+
def transpose(self) -> Series:
73+
"""
74+
Return the transpose, which is by definition self.
75+
76+
Returns:
77+
Series
78+
"""
79+
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
80+
6781
def reset_index(
6882
self,
6983
*,

0 commit comments

Comments
 (0)