Skip to content

DEPR: row-based indexing in DataFrame.__getitem__ #31334

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

Closed
wants to merge 8 commits into from

Conversation

jbrockmendel
Copy link
Member

Discussed recently in #9595. The two tests this edits are the only two that go down this path AFAICT.

@simonjayhawkins simonjayhawkins added Deprecate Functionality to remove in pandas Indexing Related to indexing on series/frames, not to indexes themselves labels Jan 27, 2020
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's first discuss this a bit more, as this is a huge change. (I am personally -1 on changing this I think)

@jbrockmendel
Copy link
Member Author

@jorisvandenbossche discussion notwithstanding, can i get your help in troubleshooting the doc build? i put in "okwarnings" to fix the previous set of failures, not clear on why dft_minute is now undefined

@@ -677,6 +677,7 @@ If index resolution is second, then the minute-accurate timestamp gives a
If the timestamp string is treated as a slice, it can be used to index ``DataFrame`` with ``[]`` as well.

.. ipython:: python
:okwarning:

dft_minute = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6]},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the whitespace alignment is off here (:okwarning: and dft_minute... should be vertically aligned)

Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbrockmendel can you give examples of what user-facing behavior is being deprecated? I'd be in favor of deprecating fallback indexing for partial string slicing dataframes with datetime indexes

In [18]: df = pd.DataFrame({"A": [1, 2]}, index=pd.date_range('2000', periods=2))

In [19]: df['2000']
Out[19]:
            A
2000-01-01  1
2000-01-02  2

.. ipython:: python
:okwarning:
Copy link
Contributor

@TomAugspurger TomAugspurger Jan 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this cause a warning? It's using loc so I wouldn't think it would.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i took the kitchen-sink approach to getting the docbuild passing, will figure out which of these can be trimmed away

@jorisvandenbossche
Copy link
Member

Repeating what I said above again: please open an issue first to discuss this.

@jreback
Copy link
Contributor

jreback commented Jan 30, 2020

iirc there is an issue about this (though woudl have to search)

@jorisvandenbossche
Copy link
Member

The issue Brock mentioned is #9595, but that is much broader (about __getitem in general), so if that is the one you are thinking about, I would propose to create a new, specific issue for this topic

@jreback
Copy link
Contributor

jreback commented Jan 30, 2020

The issue Brock mentioned is #9595, but that is much broader (about __getitem in general), so if that is the one you are thinking about, I would propose to create a new, specific issue for this topic

i believe there is a specific issue this was discussed long ago

@jbrockmendel
Copy link
Member Author

can you give examples of what user-facing behavior is being deprecated? I'd be in favor of deprecating fallback indexing for partial string slicing dataframes with datetime indexes

Exactly the example you gave. The relevant cases are where we have all of the following:

  • a DataFrame df
  • df.index is either DatetimeIndex or PeriodIndex
  • key is a date-like string
  • key not in df.columns

(these conditions are basically psuedo-code for convert_to_index_sliceable)

@jbrockmendel
Copy link
Member Author

closing to clear the queue, will reivisit

@jbrockmendel jbrockmendel added the Mothballed Temporarily-closed PR the author plans to return to label Apr 21, 2020
@jbrockmendel jbrockmendel deleted the depr-df-getitem branch November 20, 2021 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Indexing Related to indexing on series/frames, not to indexes themselves Mothballed Temporarily-closed PR the author plans to return to
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants