Tell us what’s happening:
For some reason i don’t understand i get an error in the cleaning data test of the testmodule. The error i get is this:
ERROR: test_data_cleaning (test_module.DataCleaningTestCase)
Traceback (most recent call last):
File “/home/runner/boilerplate-page-view-time-series-visualizer-1/test_module.py”, line 7, in test_data_cleaning
actual = int(time_series_visualizer.df.count(numeric_only=True))
File “/home/runner/boilerplate-page-view-time-series-visualizer-1/.pythonlibs/lib/python3.10/site-packages/pandas/core/series.py”, line 247, in wrapper
raise TypeError(f"cannot convert the series to {converter}")
TypeError: cannot convert the series to <class ‘int’>
What i can’t comprehend is that i’ve looked into the test file to see what were the expected values and all. After printing the count of the dataframe i’ve cleaned, it matches the expected result:
(The piece of the test code)
class DataCleaningTestCase(unittest.TestCase):
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.”)
and the error says something about converting to int type but the type of df.count() is already an int
Your code so far
maskclean1 = (df[‘value’] >= df[‘value’].quantile(0.025))
maskclean2 = (df[‘value’] <= df[‘value’].quantile(0.975))
print(df[‘value’].quantile(0.025))
df = df[maskclean1 & maskclean2]
print(df.count(numeric_only=True))
type(df.count(numeric_only=True))
Link to the whole code: boilerplate-page-view-time-series-visualizer (1) - Replit
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 OPR/106.0.0.0
Challenge Information:
Data Analysis with Python Projects - Page View Time Series Visualizer