You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will only happen when the number of rows is bigger than 16.
To solve this, either make sure the values setting to .loc is a pd.Series type, or use colon: instead of conditions
input_df.loc[:, 'A'] = a
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
This will only happen when the number of rows is bigger than 16.
To solve this, either make sure the values setting to .loc is a pd.Series type, or use colon: instead of conditions
input_df.loc[:, 'A'] = a
Expected Behavior
import pandas as pd
input_df = pd.DataFrame({
'A': [1] * 17,
'B': [''] * 17})
a = np.array([0, 10, 10, 20, 20, 30, 30, 30, 10, 10, 20, 20, 0, 0, 0, 10, 10])
input_df.loc[:, 'A'] = a
print(input_df)
Installed Versions
INSTALLED VERSIONS
commit : 87cfe4e
python : 3.10.6.final.0
python-bits : 64
OS : Linux
OS-release : 5.14.0-1052-oem
Version : #59-Ubuntu SMP Fri Sep 9 09:37:59 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.5.0
numpy : 1.22.1
pytz : 2022.4
dateutil : 2.8.2
setuptools : 60.2.0
pip : 21.3.1
Cython : None
pytest : 7.1.2
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 3.0.3
lxml.etree : 4.9.1
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.5.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli : 1.0.9
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.6.0
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.8.1
snappy : None
sqlalchemy : None
tables : None
tabulate : 0.8.10
xarray : None
xlrd : None
xlwt : 1.3.0
zstandard : None
tzdata : None
None
The text was updated successfully, but these errors were encountered: