this will be my first query as I'm pretty new to understanding Python and its intricacies, especially all the symbols. In my attempt to understand the ~ (grave?) symbol I know it's related to binary output. However, I ran into this predicament in a Data Camp practice session. So here's my question: What is the "~" symbol doing in the second line of code?
apps is the dataframe, 'Rating' and 'Size' are columns
x: apps_with_size_and_rating_present = apps[(apps['Rating'].isnull()) & (apps['Size'].isnull())]
print(x)
This first line, x, does not have the ~ implemented and returns a blank seaborn plot in the terminal:
However, in the duplicate same line of code including the ~ it does not have the same issue:
y: apps_with_size_and_rating_present = apps[(~apps['Rating'].isnull()) & (~apps['Size'].isnull())]
print(y)
This second line, y, works as intended
How does the first line work but not the second? Is the isnull()
the culprit or am I just not comprehending the functionality of the ~ symbol?
Any information would be appreciated!
I tried understanding the differences by running the same line of code with and without the ~ symbol but do not understand its purpose unless this is a compounded issue. What is the ~ symbol doing to the dataframe and why is it altering the graphical outputs?