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
Since Python 3.7 dictionaries are ordered, and therefore their keys are also ordered. In older pandas versions (prior to 1.1?) it was possible to create a Series from keys of a dictionary. A fix to #32582 intended to prevent an issue with sets seems to be breaking the creation of Series from keys of a dictionary.
fromcollectionsimportabcisinstance(data, abc.Set):
raiseTypeError("Set type is unordered")
will also fall on OrderedSet which is a recipe linked from the collections.abc documentation (see "See also" notes at the very bottom of the page).
It will also fail on dict().items(); the failures on keys and items are because abc.KeysView inherits from abc.MappingView and abc.Set while abc.ItemsView inherits from abc.MappingView and abc.Set. The inheritance from abc.Set is a statement about uniqueness not about being unordered.
Uh oh!
There was an error while loading. Please reload this page.
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
Problem description
Since Python 3.7 dictionaries are ordered, and therefore their keys are also ordered. In older pandas versions (prior to 1.1?) it was possible to create a
Series
from keys of a dictionary. A fix to #32582 intended to prevent an issue with sets seems to be breaking the creation ofSeries
from keys of a dictionary.Currently the following is raised:
Expected Output
Same as of
Series(list({'a': 1, 'b': 2}.keys()))
, i.e.:Output of
pd.show_versions()
INSTALLED VERSIONS
commit : f2ca0a2
python : 3.7.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-42-generic
Version : #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8
pandas : 1.1.1
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 19.2.3
setuptools : 41.2.0
Cython : None
pytest : 5.3.5
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.1
IPython : 7.12.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: