8000 BUG: to_datetime preserves name of Index argument in the result by mroeschke · Pull Request #22918 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

BUG: to_datetime preserves name of Index argument in the result #22918

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 3 commits into from
Oct 1, 2018
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
correct test
  • Loading branch information
Matt Roeschke committed Oct 1, 2018
commit a7e1410aad78f9373499fed155d16be55e5b5023
11 changes: 9 additions & 2 deletions pandas/tests/indexes/datetimes/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import calendar
import dateutil
import numpy as np
from functools import partial
from dateutil.parser import parse
from dateutil.tz.tz import tzoffset
from datetime import datetime, time
Expand Down Expand Up @@ -183,7 +182,6 @@ def test_to_datetime_format_weeks(self, cache):

@pytest.mark.parametrize("box,const,assert_equal", [
[True, pd.Index, 'assert_index_equal'],
[True, partial(pd.Index, name='foo'), 'assert_index_equal'],
[False, np.array, 'assert_numpy_array_equal']])
@pytest.mark.parametrize("fmt,dates,expected_dates", [
['%Y-%m-%d %H:%M:%S %Z',
Expand Down Expand Up @@ -235,6 +233,15 @@ def test_to_datetime_parse_timezone_malformed(self, offset):
with pytest.raises(ValueError):
pd.to_datetime([date], format=fmt)

def test_to_datetime_parse_timezone_keeps_name(self):
# GH 21697
fmt = '%Y-%m-%d %H:%M:%S %z'
arg = pd.Index(['2010-01-01 12:00:00 Z'], name='foo')
result = pd.to_datetime(arg, format=fmt)
expected = pd.DatetimeIndex(['2010-01-01 12:00:00'], tz='UTC',
name='foo')
tm.assert_index_equal(result, expected)


class TestToDatetime(object):
def test_to_datetime_pydatetime(self):
Expand Down
0