-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: DataFrame iloc does not accept Series assignment #37593
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
I don't think this is necessary. Could you show a more specific example about its usage in sktime? |
This is a very strange thing to do. I suppose this is technically a bug as a scalar could be anything, even a list-like e.g. this works
so will mark it though embedding complicated structures inside a cell is non-performant and likely has rough edges. |
take |
@GYHHAHA sktime uses exactly this format when loading multivariate time series data (see documentation) with samples in rows, channels in columns and the time dimension in the series. And this is then also the format expected by different classifiers, even if its performance may not be the best. |
Strange. This looks fine. >>>df = pd.DataFrame({'dim0':[pd.Series([1,2])], 'dim1':[pd.Series([3,4])]})
>>>df.loc[0, 'dim0']
0 1
1 2
dtype: int64 And also the following assignment raises. >>>df = pd.DataFrame([[0]])
>>>df.iloc[0,0] = [5, 3, 1]
ValueError: setting an array element with a sequence. |
i was running on an older version actually can u run on master and show the results |
Now I have checked these two on master. Still the same results. |
I think this would be fixed through #37728, even if this was not the intent :) |
well, then I will unassign myself |
Workaround for older pandas versions: use Perhaps Unfortunately, sktime-dl restricts me to using this old pandas version since I need Python 3.6. |
|
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
Code Sample, a copy-pastable example
Problem description
When trying to assign a pandas.Series to one cell of a pandas.DataFrame, the following error is raised:
ValueError: Incompatible indexer with Series
Series in DataFrames are a common thing e.g. in sktime, when working with multivariate time series data and (as the working example above shows) it is unproblematically supported by pandas. Just the assignment to one cell via .iloc seems to be erroneous.
INSTALLED VERSIONS
commit : db08276
python : 3.8.5.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.18362
machine : AMD64
processor : Intel64 Family 6 Model 61 Stepping 4, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : de_DE.cp1252
pandas : 1.1.3
numpy : 1.19.2
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.4
setuptools : 50.3.0.post20201006
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.18.1
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.5.0
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: