About why the true value is not in quote

Hi, I am working on the following project:

https://www.codecademy.com/courses/data-processing-pandas/projects/pandas-shoefly-ab-test

I wonder why my code for task 6 didn’t work( I know from pro’s video that we shouldn’t surround true or false with quote, but why?)

import codecademylib3
import pandas as pd

ad_clicks = pd.read_csv('ad_clicks.csv')

print(ad_clicks.head())

view_count=ad_clicks.groupby('utm_source').user_id.count().reset_index()

print(view_count)



ad_clicks['is_click']=~ad_clicks['ad_click_timestamp'].isnull()

clicks_by_source=ad_clicks.groupby(['utm_source','is_click'])['user_id'].count().reset_index()



clicks_pivot=clicks_by_source.pivot(columns='is_click',index='utm_source',values='user_id').reset_index()

clicks_pivot['percent_clicked']=clicks_pivot['False']/(clicks_pivot['Fasle']+clicks_pivot.['True'])

True and False are boolean values. Boolean is a data type.
'True' and 'False' are string values. Any non-empty string has a boolean value of True.
We can use a couple of built-in methods to test this:

print(type(False)) print(type('False')) print(bool(False)) print(bool('False'))
1 Like