Skip to content
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

BUG: to_datetime with unit mapping ignores utc and box arguments #23760

Closed
mroeschke opened this issue Nov 18, 2018 · 2 comments · Fixed by #24407
Closed

BUG: to_datetime with unit mapping ignores utc and box arguments #23760

mroeschke opened this issue Nov 18, 2018 · 2 comments · Fixed by #24407
Labels
Bug Datetime Datetime data dtype
Milestone

Comments

@mroeschke
Copy link
Member

In [12]: pd.__version__
Out[12]: '0.24.0.dev0+1040.g24bce1a5f'

In [13]: df = pd.DataFrame({'year': [2015, 2016],
    ...:                        'month': [2, 3],
    ...:                        'day': [4, 5]})
    ...:

In [14]: pd.to_datetime(df, box=False)
Out[14]:
0   2015-02-04
1   2016-03-05
dtype: datetime64[ns]

In [15]: pd.to_datetime(df, utc=True)
Out[15]:
0   2015-02-04
1   2016-03-05
dtype: datetime64[ns]

These arguments need to be handled directly in this function or the output

result = _assemble_from_unit_mappings(arg, errors=errors)

Expected Output

In [16]: pd.to_datetime(df, box=False).values
Out[16]:
array(['2015-02-04T00:00:00.000000000', '2016-03-05T00:00:00.000000000'],
      dtype='datetime64[ns]')

In [17]: pd.to_datetime(df, utc=True).dt.tz_localize('UTC')
Out[17]:
0   2015-02-04 00:00:00+00:00
1   2016-03-05 00:00:00+00:00
dtype: datetime64[ns, UTC]
@mroeschke mroeschke added Bug Datetime Datetime data dtype labels Nov 18, 2018
@evangelinehl
Copy link
Contributor

Hi,

Can my team and I contribute to this issue?

Thanks.

@mroeschke
Copy link
Member Author

Sure, go for it @evangelineliu

@jbrockmendel jbrockmendel moved this from Issues to Boxing/Return Types in to_datetime Improvements Nov 29, 2018
@jreback jreback added this to the 0.24.0 milestone Dec 24, 2018
@jreback jreback added Error Reporting Incorrect or improved errors from pandas and removed Error Reporting Incorrect or improved errors from pandas labels Dec 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype
Projects
No open projects
to_datetime Improvements
Boxing/Return Types
3 participants