Skip to content

to_datetime returns TypeError for invalid integer dates with %Y%m%d format #26583

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

Closed
nathalier opened this issue May 31, 2019 · 2 comments · Fixed by #26585
Closed

to_datetime returns TypeError for invalid integer dates with %Y%m%d format #26583

nathalier opened this issue May 31, 2019 · 2 comments · Fixed by #26585
Labels
Bug Datetime Datetime data dtype
Milestone

Comments

@nathalier
Copy link
Contributor

nathalier commented May 31, 2019

In [1]: pd.__version__
Out[1]: '0.25.0.dev0+625.g8154efb0c'
pd.to_datetime(20199911, format="%Y%m%d", errors='ignore')
pd.to_datetime(2019121212, format="%Y%m%d", errors='ignore')

throws "TypeError: 'int' object is unsliceable" instead of returning initial values

Traceback (most recent call last):
  File "/home/talka/projects/pandas/tmp.py", line 21, in <module>
    pd.to_datetime(2019121212, format="%Y%m%d", errors='ignore')
  File "/home/talka/projects/pandas/pandas/util/_decorators.py", line 188, in wrapper
    return func(*args, **kwargs)
  File "/home/talka/projects/pandas/pandas/core/tools/datetimes.py", line 626, in to_datetime
    result = convert_listlike(np.array([arg]), box, format)[0]
  File "/home/talka/projects/pandas/pandas/core/tools/datetimes.py", line 270, in _convert_listlike_datetimes
    arg, format, exact=exact, errors=errors)
  File "pandas/_libs/tslibs/strptime.pyx", line 149, in pandas._libs.tslibs.strptime.array_strptime
TypeError: 'int' object is unsliceable
@simonjayhawkins
Copy link
Member

thanks @nathalier for the report. if you could include the stack trace, that'll be great.

If you'd like to take a look and submit a PR would certainly be welcome.

@simonjayhawkins simonjayhawkins added this to the Contributions Welcome milestone May 31, 2019
@simonjayhawkins simonjayhawkins added Bug Datetime Datetime data dtype labels May 31, 2019
@simonjayhawkins
Copy link
Member

xref #25512 (comment)

@nathalier nathalier changed the title to_datetime returns TypeError for invalid integer dates with %Y%m%d format to_datetime returns IndexError for invalid integer dates with %Y%m%d format May 31, 2019
@nathalier nathalier changed the title to_datetime returns IndexError for invalid integer dates with %Y%m%d format to_datetime returns TypeError for invalid integer dates with %Y%m%d format May 31, 2019
nathalier added a commit to nathalier/pandas that referenced this issue Jun 1, 2019
nathalier added a commit to nathalier/pandas that referenced this issue Jun 1, 2019
nathalier added a commit to nathalier/pandas that referenced this issue Jun 1, 2019
@jreback jreback modified the milestones: Contributions Welcome, 0.25.0 Jun 1, 2019
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
None yet
Development

Successfully merging a pull request may close this issue.

3 participants