Skip to content

Commit e7a8e46

Browse files
authored
chore: remove initialization workaround in to_datetime. (#514)
* chore: Remove initialization workaround in to_datetime. * remove unused import * Update document.
1 parent 5e28ebd commit e7a8e46

File tree

3 files changed

+3
-18
lines changed

3 files changed

+3
-18
lines changed

bigframes/core/tools/datetimes.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import pandas as pd
2121

2222
import bigframes.constants as constants
23-
import bigframes.core.global_session as global_session
2423
import bigframes.dataframe
2524
import bigframes.operations as ops
2625
import bigframes.series
@@ -52,21 +51,7 @@ def to_datetime(
5251
f"to datetime is not implemented. {constants.FEEDBACK_LINK}"
5352
)
5453

55-
if not isinstance(arg, bigframes.series.Series):
56-
# This block ensures compatibility with local data formats, including
57-
# iterables and pandas.Series
58-
# TODO: Currently, data upload is performed using pandas DataFrames
59-
# combined with the `read_pandas` method due to the BigFrames DataFrame
60-
# constructor's limitations in handling various data types. Plan to update
61-
# the upload process to utilize the BigFrames DataFrame constructor directly
62-
# once it is enhanced for more related datatypes.
63-
arg = global_session.with_default_session(
64-
bigframes.session.Session.read_pandas, pd.DataFrame(arg)
65-
)
66-
if len(arg.columns) != 1:
67-
raise ValueError("Input must be 1-dimensional.")
68-
69-
arg = arg[arg.columns[0]]
54+
arg = bigframes.series.Series(arg)
7055

7156
if not utc and arg.dtype not in ("Int64", "Float64"): # type: ignore
7257
raise NotImplementedError(

third_party/bigframes_vendored/pandas/core/arrays/datetimelike.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def strftime(self, date_format: str):
2626
0 August 15, 2014, 08:15:12 AM
2727
1 February 29, 2012, 02:15:12 AM
2828
2 August 15, 2015, 03:15:12 AM
29-
Name: 0, dtype: string
29+
dtype: string
3030
3131
Args:
3232
date_format (str):

third_party/bigframes_vendored/pandas/core/tools/datetimes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def to_datetime(
4848
>>> bpd.to_datetime(list_str, format="%m-%d-%Y %H:%M", utc=True)
4949
0 2021-01-31 14:30:00+00:00
5050
1 2021-02-28 15:45:00+00:00
51-
Name: 0, dtype: timestamp[us, tz=UTC][pyarrow]
51+
dtype: timestamp[us, tz=UTC][pyarrow]
5252
5353
Converting a Series of Strings with Timezone Information:
5454

0 commit comments

Comments
 (0)