Investigate issues noticed when writing SCTs
filipsch opened this issue · 1 comments
filipsch commented
I wrote SCTs for the Analyzing police activity with pandas course (Teach, GitHub), and some SCTs I wanted to write where not working.
cc @beccarobins I will look into this as soon as I have some time, and will ping you when this is resolved (either by a fix to pythonwhat
, or if I found a workaround).
Problem 1: has_printout (Ch1Ex2)
@solution
from urllib.request import urlretrieve
file_path = 'https://s3.amazonaws.com/assets.datacamp.com/production/course_6821/datasets/police.csv'
file_name = 'police.csv'
urlretrieve(file_path, file_name)
import pandas as pd
ri = pd.read_csv('police.csv')
print(ri.head())
@sct
that doesn't pass if solution is submitted:
Ex().has_printout(0)
Problem 2: pandas chaining (Ch2 - Comparing search rates by gender)
@solution
import pandas as pd
file_path = 'https://s3.amazonaws.com/assets.datacamp.com/production/course_6821/datasets/police.csv'
ri = pd.read_csv(file_path)
ri.drop(['county_name', 'state'], axis='columns', inplace=True)
ri.dropna(subset=['driver_gender'], inplace=True)
ri['is_arrested'] = ri.is_arrested.astype('bool')
ri['stop_datetime'] = pd.to_datetime(ri.stop_date.str.cat(ri.stop_time, sep=' '))
ri.set_index('stop_datetime', inplace=True)
print(ri[ri.driver_gender == 'F'].search_conducted.mean())
@sct
that doesn't pass if solution is submitted:
Ex().check_function('ri.search_conducted.mean', index = 0, signature = sig)
It should still find the mean()
call even though there is a [ri.driver_gender == "F"]
in between.
filipsch commented
Fixed in pythonwhat 2.13.1. Visit CHANGELOG for details.