Are parentheses optional?

Hello,
I had a question on Pg. 8 of the “Data Cleaning Basics” Mission.

URL: Learn data science with Python and R projects

On the page, it says: “This method splits each string on the whitespace; the result is a series containing individual Python lists. Also note that we used parentheses to method chain over multiple lines, which makes our code easier to read.”

I did my code with and without the parentheses, and I get the same result. I don’t understand how using the parentheses helps? Can someone explain this?

My code:
laptops.loc[:,"gpu_manufacturer"] = laptops.loc[:,"gpu"].str.split().str[0]

laptops.loc[:,'cpu_manufacturer'] = laptops.loc[:,'cpu'].str.split().str[0]

cpu_manufacturer_counts=laptops.loc[:,'cpu_manufacturer'].value_counts()

It won’t run without the parentheses over multiple lines:

image

1 Like

Ah! OK, now I get it. Thanks so much @Bruno.