TypeError: cannot convert the series to <class 'int'> - Page view time series project

Hi there, I am getting an error for my code in the page view time series python data analysis project. This is my code. My plots are all correct and this is the only error I am getting.

I know that my error is regarding the df.count() and that it has 3 columns instead of one. However, I am still confused about where and how to edit my code. Since the error message says:

Traceback (most recent call last):
  File "/home/runner/page-view-time-series/test_module.py", line 7, in test_data_cleaning
    actual = int(time_series_visualizer.df.count(numeric_only=True))
  File "/nix/store/011fpws3ix9hym56a8q54h08df5ymhab-python3.8-pandas-1.2.4/lib/python3.8/site-packages/pandas/core/series.py", line 141, in wrapper
    raise TypeError(f"cannot convert the series to {converter}")
TypeError: cannot convert the series to <class 'int'>

I tried using df.drop() in the data cleaning part of the project to drop the month and year columns and keep only the value column but I don’t think that is where the code goes. I am not sure how to go about this because I don’t know where exactly the error is and where I should be putting the code to make sure there is only column instead of 3. Could someone please help with this? thank you!!

Thing is at that point df should have one column. One of the function modifies the df, instead using the copy of it.

1 Like

Hello, I have a similar problem:
I included the function (df.count(numeric_only=True)) and (df.shape) so I could see the result generated and it is a series, with one value 1238 (expected) of dtype=int64

However I found what was suggested and after fixing it the error cleared.

Thank you!