-
-
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
DEPR: Deprecate from_items #18529
DEPR: Deprecate from_items #18529
Conversation
@reidy-p can you look at the original issue; do we have a replacement for suppose we could just add an optional @jorisvandenbossche @TomAugspurger since we are doing pretty much everything with the main constructors and not the |
-1 on adding even more to the main DataFrame constructor. The ship has not fully sailed since If there is no actual alternative for Although I suppose you can do it with |
cc @wesm as you recently posted an issue related to |
Yeah, you can use
This PR also seems to be failing a lot of tests because when I replaced |
2d4e46b
to
80dcec6
Compare
Codecov Report
@@ Coverage Diff @@
## master #18529 +/- ##
==========================================
- Coverage 91.35% 91.33% -0.02%
==========================================
Files 164 164
Lines 49802 49804 +2
==========================================
- Hits 45496 45489 -7
- Misses 4306 4315 +9
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18529 +/- ##
==========================================
- Coverage 91.62% 91.61% -0.01%
==========================================
Files 150 150
Lines 48724 48725 +1
==========================================
- Hits 44642 44640 -2
- Misses 4082 4085 +3
Continue to review full report at Codecov.
|
if we can deprecate |
80dcec6
to
42601a5
Compare
pandas/tests/io/test_excel.py
Outdated
("FloatCol", [1.25, 2.25, 1.83, 1.92, 0.0000000005]), | ||
("BoolCol", [True, False, True, True, False]), | ||
("StrCol", [1, 2, 3, 4, 5]), | ||
expected = DataFrame.from_dict(OrderedDict({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to change the contents of the OrderedDict from a dict to a list of tuples to ensure that order is maintained to stop the tests failing
42601a5
to
2bd0afe
Compare
pandas/core/frame.py
Outdated
@@ -1242,6 +1242,11 @@ def to_records(self, index=True, convert_datetime64=True): | |||
@classmethod | |||
def from_items(cls, items, columns=None, orient='columns'): | |||
""" | |||
DEPRECATED: from_items is deprecated and will be removed in a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we no longer use DEPRECATED (it will fail the linter), instead use ..deprecated (the sphinx directive)
@@ -363,12 +363,12 @@ def test_reader_converters(self): | |||
|
|||
basename = 'test_converters' | |||
|
|||
expected = DataFrame.from_items([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feel free to change some / most constructions with from items entirely (rather than catch the deprecation warning)
2bd0afe
to
892dfd4
Compare
@@ -1256,13 +1283,13 @@ def test_constructor_column_duplicates(self): | |||
|
|||
tm.assert_frame_equal(df, edf) | |||
|
|||
idf = DataFrame.from_items( | |||
[('a', [8]), ('a', [5])], columns=['a', 'a']) | |||
idf = DataFrame.from_records([(8, 5)], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that some of the dataframe constructors don't allow duplicated columns while others do so I had to change the from_items
in this test to from_records
and from_dict(OrderedDict())
to get the test passing. But I'm not sure if it still tests for the original issue correctly (#2079)
All of the other tests in this file using from_items
are directly testing from_items
so I left the check for the deprecation warning rather than trying to replace from_items
with a different constructor.
892dfd4
to
b22b472
Compare
b22b472
to
1838f65
Compare
thanks! |
at least 1 deprecation warnings are still showing, can you convert (and see if any more)
|
We have an example in the documentation about
Also, the deprecation warning in that case is not really correct, as simply changing to
Should we add a |
@jorisvandenbossche yes, these are good points. As I show above, it is possible to recreate the functionality of |
I think it would be rather easy to add a @reidy-p would you like to do a PR for this? |
that sounds reasonable to me, adding a kwarg to |
@jorisvandenbossche yes I’ll try and do a PR |
I haven't seen any mention that the
|
When running the test `wbia/algo/graph/refresh.py::demo_refresh:0`: ``` Traceback (most recent call last): File "/virtualenv/env3/lib/python3.6/site-packages/xdoctest/doctest_example.py", line 556, in run exec(code, test_globals) File "<doctest:/wbia/wildbook-ia/wbia/algo/graph/refresh.py::demo_refresh:0>", line rel: 3, abs: 218, in <module> >>> demo_refresh() File "/wbia/wildbook-ia/wbia/algo/graph/refresh.py", line 232, in demo_refresh ys = infr.match_state_df(edges)[POSTV].values File "/wbia/wildbook-ia/wbia/algo/graph/mixin_groundtruth.py", line 56, in match_state_df match_state_df = pd.DataFrame.from_items( AttributeError: type object 'DataFrame' has no attribute 'from_items' ``` Looking at the panda changelog, it seems `from_items` was removed in `v1.0.0` and replaced by `from_dict`. See pandas-dev/pandas#18529.
When running the test `wbia/algo/graph/refresh.py::demo_refresh:0`: ``` Traceback (most recent call last): File "/virtualenv/env3/lib/python3.6/site-packages/xdoctest/doctest_example.py", line 556, in run exec(code, test_globals) File "<doctest:/wbia/wildbook-ia/wbia/algo/graph/refresh.py::demo_refresh:0>", line rel: 3, abs: 218, in <module> >>> demo_refresh() File "/wbia/wildbook-ia/wbia/algo/graph/refresh.py", line 232, in demo_refresh ys = infr.match_state_df(edges)[POSTV].values File "/wbia/wildbook-ia/wbia/algo/graph/mixin_groundtruth.py", line 56, in match_state_df match_state_df = pd.DataFrame.from_items( AttributeError: type object 'DataFrame' has no attribute 'from_items' ``` Looking at the panda changelog, it seems `from_items` was removed in `v1.0.0` and replaced by `from_dict`. See pandas-dev/pandas#18529.
When running the test `wbia/algo/graph/refresh.py::demo_refresh:0`: ``` Traceback (most recent call last): File "/virtualenv/env3/lib/python3.6/site-packages/xdoctest/doctest_example.py", line 556, in run exec(code, test_globals) File "<doctest:/wbia/wildbook-ia/wbia/algo/graph/refresh.py::demo_refresh:0>", line rel: 3, abs: 218, in <module> >>> demo_refresh() File "/wbia/wildbook-ia/wbia/algo/graph/refresh.py", line 232, in demo_refresh ys = infr.match_state_df(edges)[POSTV].values File "/wbia/wildbook-ia/wbia/algo/graph/mixin_groundtruth.py", line 56, in match_state_df match_state_df = pd.DataFrame.from_items( AttributeError: type object 'DataFrame' has no attribute 'from_items' ``` Looking at the panda changelog, it seems `from_items` was removed in `v1.0.0` and replaced by `from_dict`. See pandas-dev/pandas#18529.
git diff upstream/master -u -- "*.py" | flake8 --diff