-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
astype not converting timedelta and datetime strings #22100
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
Comments
The bug is still there. Please fix. |
hence the open status of this issue @azelk you are welcome to volunteer a patch |
I believe this is related, so I thought I'd share. (If distinct enough, please tell me & I can open a new issue.) Summary: Below is a reproducible example similar to a project where I am trying to change large batches of Pandas DataFrame columns from 'string' to 'datetime64[ns]'. In doing so, I have gotten ValueErrors when astype() cannot convert the string date columns into date dtypes. The issue seems arise when The example below shows that to_datetime() is perfectly capable of handling both objects & 'string' dtypes, both with and without NA, and both with and without different date formats. However, astype() cannot handle the (a)+(b) situation. Thanks for any thoughts! Note: I'm running this in Visual Studio Code, hence the "#%%" interactive sections:
|
thanks for the report - you should use closing then |
@MarcoGorelli , yes AND can "astype" be fixed to incorporate the improvements of "to_datetime"? |
-1 on adding to astype the reason we have the to_ functions is to expose a number options for conversion astype is quite simple and api and it should stay that way |
Code Sample, a copy-pastable example if possible
Same with datetime.
Expected Output
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: 114f415
python: 3.6.6.final.0
python-bits: 64
OS: Linux
OS-release: 4.13.0-46-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.24.0.dev0+365.g114f41534.dirty
pytest: 3.6.2
pip: 10.0.1
setuptools: 39.2.0
Cython: 0.28.3
numpy: 1.14.5
scipy: 1.1.0
pyarrow: 0.9.0
xarray: 0.10.7
IPython: 6.4.0
sphinx: 1.7.5
patsy: 0.5.0
dateutil: 2.7.3
pytz: 2018.4
blosc: None
bottleneck: 1.2.1
tables: 3.4.4
numexpr: 2.6.5
feather: 0.4.0
matplotlib: 2.2.2
openpyxl: 2.5.4
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.0.5
lxml: 4.2.2
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: 1.2.8
pymysql: 0.8.1
psycopg2: None
jinja2: 2.10
s3fs: 0.1.5
fastparquet: 0.1.5
pandas_gbq: None
pandas_datareader: None
gcsfs: 0.1.0
The text was updated successfully, but these errors were encountered: