Search code examples
pythonvaex

How to use named selection for filtering in Vaex


I created 2 named selections

df.select(df.x => 2,name='bigger')
df.select(df.x < 2,name='smaller')

and it's cool, I can use the selection parameter so many (ie statistical) functions offer, for example

df.count('*',selection='bigger')

but is there also a way to use the named selection in a filter? Something like

df['bigger']

Solution

  • Well that syntax df['bigger'] is accessing a column (or expression) in vaex that is called 'bigger'.

    However, you can do: df.filter('bigger') and will give you a filtered dataframe.

    Note that, while similar in some ways, filters and selections are a bit different, and each has its own place when using vaex.