-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
API DesignEnhancementIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselvesMaster TrackerHigh level tracker for similar issuesHigh level tracker for similar issuesNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further actionReshapingConcat, Merge/Join, Stack/Unstack, ExplodeConcat, Merge/Join, Stack/Unstack, Explode
Milestone
Description
accept callables
(not changed, see ENH: Allow where/mask/Indexers to accept callable #12539).query
-
.where/.mask
(ENH: Allow where/mask/Indexers to accept callable #12539) -
.loc
(and indexers) (ENH: Allow where/mask/Indexers to accept callable #12539)
In [4]: df = DataFrame({'A' : [1,2,3,4], 'B' : ['a',np.nan,'b','a']})
In [5]: df
Out[5]:
A B
0 1 a
1 2 NaN
2 3 b
3 4 a
an operation that changes the shape of the DataFrame
In [9]: res = df.dropna()
In [10]: res[res.B=='a']
Out[10]:
A B
0 1 a
3 4 a
can be done like this
In [8]: df.dropna().pipe(lambda x: x[x.B=='a'])
Out[8]:
A B
0 1 a
3 4 a
SQL calls this select
, which pandas has, but both select/filter
are used for filtering LABELS (and not data).
I suppose making this work:
df.dropna().loc[lambda x: x[x.B=='a']]
is maybe a slight enhancement of this
any thoughts?
Metadata
Metadata
Assignees
Labels
API DesignEnhancementIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselvesMaster TrackerHigh level tracker for similar issuesHigh level tracker for similar issuesNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further actionReshapingConcat, Merge/Join, Stack/Unstack, ExplodeConcat, Merge/Join, Stack/Unstack, Explode