-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Unexpected results creating an empty Series #16737
Comments
For what it's worth, from the point of view of teaching, my suggestion would be to act as if there is no such thing as an empty That said, this is strange - cause seems to be:
|
Thanks for looking into this. I see your point about building a Python data structure first, but (in case you are interested) I am working on a new book that teaches modeling and simulation for people who have not programmed before, and I am taking a top-down approach where I teach high-level tools, like Pandas, before lower-level tools, like Python data structures. So at this point, the reader has not yet seen lists or dictionaries, which is why I would prefer to make the empty list disappear. |
It seems that in our test, we do expect this mismatch between two empty Series
Current behavior will fail if we remove |
@BranYang yeah there is a difference in contruction.
This should prob not be the case. This might cause a number of test failures, but would be to good to investigate. |
take |
Can we do this immediately or should we issue a FutureWarning before changing this? Or will this be done when changing the dtype of empty Series from float to object? |
if this needs a deprecation, itd be nice to get it in so we can change in 2.0 |
It looks like this behavior changed at some point, so the example works now. I'm not sure if I should close the issue, but maybe someone should. Maybe @mroeschke , since you had the last touch on this issue. |
Yeah this looks to work and I think we have tests for this so closing |
Code Sample, a copy-pastable example if possible
Problem description
When I create an empty series like this
model = Series([])
, I get the expected behavior when I try to set an element.When I create an empty series like this
model = Series()
, I was hoping for the same behavior. It seems like a Series created withdata=None
isn't good for much. Or maybe there's a reason I would want one?I realize that providing
[]
as an argument is not a big deal, but since I am using it as a teaching example, it would be nice to have one less thing to explain.Output of
pd.show_versions()
pandas: 0.20.1
pytest: 2.8.5
pip: 8.1.1
setuptools: 20.3
Cython: 0.23.4
numpy: 1.11.0
scipy: 0.17.0
xarray: None
IPython: 4.1.2
sphinx: 1.3.5
patsy: 0.4.1
dateutil: 2.5.1
pytz: 2016.2
blosc: None
bottleneck: 1.2.1
tables: 3.3.0
numexpr: 2.5.2
feather: None
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.8.4
lxml: 3.6.0
bs4: 4.4.1
html5lib: 0.999
sqlalchemy: 1.0.12
pymysql: None
psycopg2: None
jinja2: 2.8
s3fs: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: