Subscribe to my email list now at http://jauyeung.net/subscribe/
Follow me on Twitter at https://twitter.com/AuMayeung
Many more articles at http...
For further actions, you may consider blocking this person and/or reporting abuse
Great post, I had no idea there was a
clear()
method. You're missing out on one of my favorite features though! The*
operator. I commonly use it along side list comprehensions.For example take a pandas
DataFrame
and get all of the columns that include"price"
in their name.Thanks for reading.
You mean make a filtered list with lost comprehension?
Or you mean using * to repeat items?
Lol, good catch. 😳 I think I took a break between the comment and finding a good example. Here is a real example of nearly the same thing if the DataFrame was a pyspark DataFrame. pyspark.select takes in column names as
*args
df.select('us_price', 'eu_price')
They can be selected programatically with a list comprehension and *unpacking.
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.
Thanks John for this nice summary on the list. I think you forget a banana in the print of fruit_copy after fruit_copy.append('banana') and I like the bananas ;)
Thanks so much for reading and catching that mistake. I corrected it now.
what's the difference between l.count() and len(l)?
There's no difference.
I guess there is a huge difference between them
check the example below
Yes. You're right