https://www.codecademy.com/practice/projects/this-is-jeopardy
In this course, I downloaded CSV file and manipulated DataFrame as instructed. But when i implemented third step, i could find out there’s something weird.
The description said, Note that in this example, we found 152 rows by filtering the entire dataset.
But the result i got is 49 rows only. My code is below:
import pandas as pd
pd.set_option('display.max_colwidth', -1)
df = pd.read_csv('jeopardy.csv')
print(df.head())
df.rename(columns={
' Air Date': 'Air Date',
' Round': 'Round',
' Category': 'Category',
' Value': 'Value',
' Question': 'Question',
' Answer': 'Answer'
}, inplace=True)
print(df.head())
def filter_strings(word_list):
filtered_df = df[ df.apply(lambda row: all([word in row['Question'] for word in word_list]), axis=1) ]
return filtered_df
filtered_df = filter_strings(['King', 'England'])
print(filtered_df.head())
print('filtered_df.index: ' + str(len(filtered_df.index))) # filterd_df.index: 49
Plz check out is there any missed data in leopardy.csv or any mistake in my code.