A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/11485 below:

chained reshaping ops · Issue #11485 · pandas-dev/pandas · GitHub

accept callables

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?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4