I see. The list comprehension is used as a predicate?
Not sure what you mean by predicate, the list comprehension is a filter.
price_cols = [col for col in df.columns if 'price' in col] df_prices = df.select(*price_cols)
Here is a generally relatable example using the print statement
[ins] In [1]: fruits = ['apple', 'orange', 'orange', 'grape', 'pear'] [ins] In [2]: print(fruits) ['apple', 'orange', 'orange', 'grape', 'pear'] [ins] In [3]: print('apple', 'orange', 'orange', 'grape', 'pear') apple orange orange grape pear [ins] In [4]: print(*fruits) apple orange orange grape pear [ins] In [5]: print(*[fruit for fruit in fruits if 'p' in fruit]) apple grape pear
That makes sense. I haven't seen this documented in many places. That's probably why I missed this.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I see. The list comprehension is used as a predicate?
Not sure what you mean by predicate, the list comprehension is a filter.
Here is a generally relatable example using the print statement
That makes sense. I haven't seen this documented in many places. That's probably why I missed this.