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: inconsistent processing of datetime in format '%Y-%m-%dT%H:%M:%S' depending on whether there is a time or it is 00:00:00 #60431

Closed
2 of 3 tasks
bron-lundbeck opened this issue Nov 27, 2024 · 2 comments
Labels
Arrow pyarrow functionality Bug Closing Candidate May be closeable, needs more eyeballs Duplicate Report Duplicate issue or pull request IO CSV read_csv, to_csv

Comments

@bron-lundbeck
Copy link

bron-lundbeck commented Nov 27, 2024

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

##filename should be a csv loaded with following values:
# ID	Start_Date	Report_Status_Effective_Date
# 1	2023-04-27T10:00:00	2023-05-26T00:00:00
# 2	2026-08-12T22:00:00	2026-08-13T00:00:00
# 3	2028-03-23T04:00:00	2028-03-23T00:00:00
# 4	2022-12-28T12:00:00	2023-01-17T00:00:00
# 5	2022-02-09T09:33:00	2023-01-04T00:00:00
# 6	2023-06-21T05:00:00	2023-07-11T00:00:00
# 7	2024-11-28T03:00:00	2024-11-28T00:00:00
# 8	2024-03-21T13:00:00	2024-06-27T00:00:00
# 9	2023-12-01T12:00:00	2024-01-22T00:00:00

df = pd.read_csv(filename, dtype=str, engine='pyarrow', keep_default_na=False)
print(df)

Issue Description

The outcome of the above inconsistently removes the "T" from the date format, like so:

        START_DATE STATUS_EFFECTIVE_DATE

0 2023-04-27T10:00:00 2023-04-27 00:00:00
1 2026-08-12T22:00:00 2026-08-13 00:00:00
2 2028-03-23T04:00:00 2028-03-23 00:00:00
3 2022-12-28T12:00:00 2022-12-28 00:00:00
4 2022-02-09T09:33:00 2022-02-09 00:00:00
5 2023-06-21T05:00:00 2023-06-21 00:00:00
6 2024-11-28T03:00:00 2024-11-28 00:00:00
7 2024-03-21T13:00:00 2024-03-21 00:00:00
8 2023-12-01T12:00:00 2023-12-01 00:00:00
9 2024-11-19T09:00:00 2024-10-30 00:00:00

Note above how the "T" remains in the left most column where there are time values, and is removed on the right column where all time values are 00:00:00
This makes it impossible to map the dates consistently with the format '%Y-%m-%dT%H:%M:%S' .
Note this issue requires all values in a column to have time = 00:00:00

Expected Behavior

The two columns should still have the "T" between date and time

Installed Versions

INSTALLED VERSIONS

commit : 0691c5c
python : 3.11.10
python-bits : 64
OS : Linux
OS-release : 6.5.0-1025-azure
Version : #26~22.04.1-Ubuntu SMP Thu Jul 11 22:33:04 UTC 2024
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.2.3
numpy : 2.1.2
pytz : 2024.2
dateutil : 2.9.0.post0
pip : 24.2
Cython : None
sphinx : None
IPython : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2024.10.0
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.4
lxml.etree : 5.3.0
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : 17.0.0
pyreadstat : None
pytest : 7.4.4
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : 0.9.0
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2024.2
qtpy : None
pyqt5 : None

@bron-lundbeck bron-lundbeck added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 27, 2024
@asishm
Copy link
Contributor

asishm commented Nov 28, 2024

Thanks for the report, this is likely a duplicate of #57666

@asishm asishm added Duplicate Report Duplicate issue or pull request IO CSV read_csv, to_csv Closing Candidate May be closeable, needs more eyeballs Arrow pyarrow functionality labels Nov 28, 2024
@rhshadrach
Copy link
Member

Agreed @asishm - closing.

@rhshadrach rhshadrach removed the Needs Triage Issue that has not been reviewed by a pandas team member label Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality Bug Closing Candidate May be closeable, needs more eyeballs Duplicate Report Duplicate issue or pull request IO CSV read_csv, to_csv
Projects
None yet
Development

No branches or pull requests

3 participants