-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support Series.dt.strftime (#453)
* feat: support Series.dt.strftime * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * address comments * fix imports * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
1df0140
commit 8f6e955
Showing
5 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
third_party/bigframes_vendored/pandas/core/arrays/datetimelike.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Contains code from https://github.com/pandas-dev/pandas/blob/main/pandas/core/arrays/datetimelike.py | ||
|
||
from bigframes import constants | ||
|
||
|
||
class DatelikeOps: | ||
def strftime(self, date_format: str): | ||
""" | ||
Convert to string Series using specified date_format. | ||
Return a Series of formatted strings specified by date_format. Details | ||
of the string format can be found in `BigQuery format elements doc | ||
<%(https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements)s>`__. | ||
**Examples:** | ||
>>> import bigframes.pandas as bpd | ||
>>> bpd.options.display.progress_bar = None | ||
>>> s = bpd.to_datetime( | ||
... ['2014-08-15 08:15:12', '2012-02-29 08:15:12+06:00', '2015-08-15 08:15:12+05:00'], | ||
... utc=True | ||
... ).astype("timestamp[us, tz=UTC][pyarrow]") | ||
>>> s.dt.strftime("%B %d, %Y, %r") | ||
0 August 15, 2014, 08:15:12 AM | ||
1 February 29, 2012, 02:15:12 AM | ||
2 August 15, 2015, 03:15:12 AM | ||
Name: 0, dtype: string | ||
Args: | ||
date_format (str): | ||
Date format string (e.g. "%Y-%m-%d"). | ||
Returns: | ||
bigframes.series.Series of formatted strings. | ||
""" | ||
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) |