Pandas version checks
-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of pandas.
-
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
import numpy as np
# Sample DataFrame
data = {
'race_id': [1, 1, 2, 2, 3, 3],
'value': [10, 20, 30, 40, 50, 60]
}
df = pd.DataFrame(data)
# Chunk processing
chunks = np.array_split(df, 2)
for chunk in chunks:
print(chunk)
Issue Description
Description: I have encountered a critical bug in the chunk processing functionality of pandas. When performing iteration on specific non-NULL IDs, the chunk processing results in those IDs becoming NULL. This issue also causes related values to be recognized as NULL within the DataFrame, leading to incorrect processing
Expected Behavior
Steps to Reproduce:
Perform iteration on a DataFrame with specific non-NULL IDs.
Observe that during chunk processing, those IDs become NULL.
Related values within the DataFrame are also recognized as NULL, causing incorrect processing.
Expected Behavior: The IDs should remain non-NULL during chunk processing, and related values should be processed correctly.
Actual Behavior: The IDs become NULL during chunk processing, and related values are recognized as NULL, leading to incorrect processing.
Additional Context: This bug significantly impacts the reliability of chunk processing in pandas, making it difficult to perform accurate data analysis. A prompt resolution would be greatly appreciated.
Installed Versions
Environment:
pandas version: [Version: 2.2.2]
Python version: [3.11.9 64bit]
Operating System: [windows10 64bit]
Replace this line with the output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit : d9cdd2ee5a58015ef6f4d15c7226110c9aab8140
python : 3.11.9.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19045
machine : AMD64
processor : Intel64 Family 6 Model 78 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : Japanese_Japan.932
pandas : 2.2.2
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : 65.5.0
pip : 24.2
Cython : 3.0.10
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 5.2.1
html5lib : 1.1
pymysql : 1.4.6
psycopg2 : None
jinja2 : 3.1.4
IPython : 8.23.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.13.0
sqlalchemy : 2.0.30
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None
**Comment From: Aloqeely**
Thanks for the report! I am unable to reproduce this bug, can you double check if the code snippet you provided produces the bug?
On a side note, it's better to use `df.iloc[]` instead of `np.array_split` since that will produce an array instead of a DataFrame in the next pandas release, which is probably not what you want.
**Comment From: rhshadrach**
Cannot produce on 2.2 as well. @hiroly2317 - can you post the output you get.
**Comment From: mroeschke**
Closing as needing information