-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Concat for two dataframes row-wise fails if one of columns is datetime and iterrows was used #56779
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
Can you post the traceback? |
I am not able to replicate on main. |
|
I ran into a similar issue today when concatenating two dataframes that had a mix of |
That appears to be the issue here @cameronbronstein - while concat on 2.2.x and main now succeed, the DataFrame originally has |
take |
Looks like the unit of the datetime type gets set to a default I've played around with it a bit, when every column is a datetime type, there is no issue, but when only one or a few are datetime types, it converts them to Here is the check I implemented: |
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
Issue Description
The
pd.concat
of two dataframes fails when two conditions are met:datetime
(if it isdate
everything works though)concat
was constructed using.iterrows()
Changing
iterrows()
toitertuples()
(in case something broke down in types) doesn't solve the problemExpected Behavior
It works with the
date
object, so would expect it to be a bug.Installed Versions
INSTALLED VERSIONS
commit : a671b5a
python : 3.11.7.final.0
python-bits : 64
OS : Darwin
OS-release : 23.1.0
Version : Darwin Kernel Version 23.1.0: Mon Oct 9 21:28:12 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T8103
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.1.4
numpy : 1.26.3
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 68.2.2
pip : 23.3.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader : None
bs4 : None
bottleneck : 1.3.5
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : 2.8.7
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: