TypeError: cannot convert the series to <class 'int'>

i am getting the TypeError: cannot convert the series to <class 'int> and I do not know why.
it is regarding the test_data_cleaning case

# Import data (Make sure to parse dates. Consider setting index column to 'date'.)
df = pd.read_csv("fcc-forum-pageviews.csv", parse_dates=True)
df = df.set_index('date')

# Clean data

df = df[(df['value'] >= (df['value'].quantile(0.025))) &(df['value'] <= (df['value'].quantile(0.975)))]

I saw that each graph needs a copy - which I did , but what I don’t get is why this error comes up during cleaning.
I tried

  • changing format to float and int32,
  • dropping index column
  • resetting index column then dropping

This is the error:

ERROR: test_data_cleaning (test_module.DataCleaningTestCase)
Traceback (most recent call last):
  File "/home/runner/boilerplate-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))
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pandas/core/series.py", line 139, in wrapper
    raise TypeError(f"cannot convert the series to {converter}")
TypeError: cannot convert the series to <class 'int'>

I looked at; Page View Time Series Visualizer and Page View Time Series Visualizer test error but found no solution. this last one has actual = int(time_series_visualizer.df.count(numeric_only=True)) so that shouldn’t be the problem.
Has anyone else faced this issue?

These lines looks okay. Most likely some other place is causing the issue. Can you show the rest of the code, ideally on repl.it as that would helping make easier?

I am now on that same error and I cannot solve it

Share a link to your project with the code and maybe we can help you.

You are trying to cast a pandas Series object into an int, that won’t work.
In the link you’ve shown it had actual = int(time_series_visualizer.df.count()[0]) notice the [0] meaning that they are indexing the first element in the Serie. This means that it’s not a Serie anymore but an individual number.

If you want to cast the whole Serie to int try this: s.astype(int). Otherwise if you just want to cast one value, make sure that you don’t have a Serie but instead a singular value!

Hope it helps!