Skip to content

feat: add aliases for several series properties #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions bigframes/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ def shape(self) -> typing.Tuple[int]:
def size(self) -> int:
return self.shape[0]

@property
def ndim(self) -> int:
return 1

@property
def empty(self) -> bool:
return self.shape[0] == 0
Expand All @@ -123,6 +127,13 @@ def query_job(self) -> Optional[bigquery.QueryJob]:
def struct(self) -> structs.StructAccessor:
return structs.StructAccessor(self._block)

@property
def T(self) -> Series:
return self.transpose()

def transpose(self) -> Series:
return self

def _set_internal_query_job(self, query_job: bigquery.QueryJob):
self._query_job = query_job

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

pad = ffill

def bfill(self, *, limit: typing.Optional[int] = None) -> Series:
window = bigframes.core.WindowSpec(preceding=0, following=limit)
return self._apply_window_op(agg_ops.FirstNonNullOp(), window)
Expand Down Expand Up @@ -743,6 +756,8 @@ def agg(self, func: str | typing.Sequence[str]) -> scalars.Scalar | Series:
agg_ops.lookup_agg_func(typing.cast(str, func))
)

aggregate = agg

def skew(self):
count = self.count()
if count < 3:
Expand Down
14 changes: 14 additions & 0 deletions third_party/bigframes_vendored/pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ def name(self) -> Hashable:
"""
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)

@property
def T(self) -> Series:
"""Return the transpose, which is by definition self."""
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)

def transpose(self) -> Series:
"""
Return the transpose, which is by definition self.

Returns:
Series
"""
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)

def reset_index(
self,
*,
Expand Down