In the “A/B Testing for Shoefly.com’” project for the Aggregates in Pandas lesson in the course Data Analysis With Pandas, there is the following piece of code presented as a solution to question 6:
clicks_pivot[‘percent_clicked’] = (clicks_pivot[True] * 100)/(clicks_pivot[True] + clicks_pivot[False])
Here is a link to the project:
Throughout the course it was reiterated that columns in a DataFrame should be referred to as either df.column_name or df[‘column_name’]. However none of those formats seemed to work when I tried to define the columns in a pivot table as either clicks_pivot.True or clicks_pivot[‘True’] as it gave me errors. There is no explanation as to why clicks_pivot[True] works here neither in the course nor in the explanatory video at the end of the project.
Could anybody please elaborate why defining a column as df[column_name] without quotations works for a pivot table?