Data Analysis with Python Projects - Page View Time Series Visualizer

Tell us what’s happening:
I’ve almost completed this challenge now but have hit a brick wall trying to solve this error that pops up. I don’t fully understand what it’s telling me.

“TypeError: cannot convert this series to <class ‘int’>”

I’ve attempted methods such as the astype() but that didn’t get me anywhere.

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

Challenge: Data Analysis with Python Projects - Page View Time Series Visualizer

Link to the challenge:

Read the error further:

File “/home/runner/ArunBarnes-page-view-time-series-visualizer-2/test_module.py”, line 7, in test_data_cleaning
actual = int(time_series_visualizer.df.count(numeric_only=True))

Here is the test that you are failing:

def test_data_cleaning(self):
actual = int(time_series_visualizer.df.count(numeric_only=True))
expected = 1238
self.assertEqual(actual, expected, “Expected DataFrame count after cleaning to be 1238.”)

I added a print here:

# Clean data
df = df[
  (df['value'] >= df['value'].quantile(0.025)) &
  (df['value'] <= df['value'].quantile(0.975))
]
print(df.count)

This does return 1238:

[1238 rows x 1 columns]>

However, if I move the print statement to the end of your boxplot function, it returns “1238 rows, 3 columns”. So the test is not able to convert 3 columns into an integer.

The problem is with the beginning of your barplot. Read this instruction:

# Copy and modify data for monthly bar plot

You do this correctly for your boxplot, but you skipped that step in your bar plot and df gets modified, breaking the test.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.