-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Make pd.Series(index=values) equivalent to pd.Series(index=pd.Index(values))? #18484
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
This suggests the above is partly indended... but there should be a better fix. |
|
I hate this kw. |
It gets better: In [2]: pd.Index([[0, 1, 2], [3, 4, 5]])
Out[2]: Index([[0, 1, 2], [3, 4, 5]], dtype='object')
In [3]: pd.Series(index=[[0, 1, 2], [3, 4, 5]])
Out[3]:
0 3 NaN
1 4 NaN
2 5 NaN
dtype: float64 ... which is not "tupleization" (notice the orientation)! The interpretation of lists as index levels in |
[2] is invalid but prob not checked these are not hashable sub elements absolutely we do not want to add complexity like this |
Yes, and I didn't know this worked like that in Series. I would rather disallow it there as well. |
I'm totally fine with disallowing this feature, but it is precisely the main task of (and assuming we didn't want to drop it, integrating it into |
It's not accidental, that's true, but that test is more testing that the Period is preserved and not converted into an int, than testing the "index levels as list" feature I think. Although there are maybe other more explicit tests. |
OK, what about this related behavior? (Just for reference), it is used at ~20 places in testing. In [2]: s = pd.Series([1, 2, 3])
In [3]: s.index = [['a', 'b', 'b'], ['d', 'd', 'e']]
In [4]: s
Out[4]:
a d 1
b d 2
e 3
dtype: int64 In [5]: s.index = [pd.Index(['a', 'b', 'b']), pd.Index(['d', 'd', 'e'])] Do we like them? |
By the way: |
[3] is pretty clear. We coerce this to a MultiIndex. [5] should work as well (to a MI). I see why you think #18484 (comment) is inconsistent. are: a) b) the same, where |
OK. So finally if I understand correctly the plan is to
|
the original intent of |
Code Sample, a copy-pastable example if possible
Problem description
I guess
Out[3]:
andOut[6]:
are wrong.Expected Output
Out[4]:
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.5.3.final.0
python-bits: 64
OS: Linux
OS-release: 4.9.0-4-amd64
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8
pandas: 0.22.0.dev0+202.g97bd66ea8
pytest: 3.0.6
pip: 9.0.1
setuptools: 33.1.1
Cython: 0.25.2
numpy: 1.12.1
scipy: 0.18.1
pyarrow: None
xarray: None
IPython: 5.2.2
sphinx: None
patsy: 0.4.1+dev
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: 1.2.0
tables: 3.3.0
numexpr: 2.6.1
feather: 0.3.1
matplotlib: 2.0.0
openpyxl: 2.3.0
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: None
lxml: 3.7.1
bs4: 4.5.3
html5lib: 0.999999999
sqlalchemy: 1.0.15
pymysql: None
psycopg2: None
jinja2: 2.8
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: