# Page View Time Series - TypeError series to \<class 'int'\>

**URL:** <https://forum.freecodecamp.org/t/page-view-time-series-typeerror-series-to-class-int/543634>\
**Category:** I Built This\
**Created:** [August 16, 2022, 8:05pm UTC](https://forum.freecodecamp.org/t/page-view-time-series-typeerror-series-to-class-int/543634 "2022-08-16T20:05:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![soupybeanie](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/soupybeanie/32/267892_2.png) [@soupybeanie](https://forum.freecodecamp.org/u/soupybeanie)\
**Post date:** [August 16, 2022, 8:05pm UTC](https://forum.freecodecamp.org/t/page-view-time-series-typeerror-series-to-class-int/543634/1 "2022-08-16T20:05:46Z")

</div>

Hi there, I am receiving an error for my code for the page view time series visualizer project and I am unsure of how to tackle this error.

Here is my code: [this](https://replit.com/@soupybeanie/page-view-time-series#time_series_visualizer.py)

When I run the code, I get an error saying the following:

```auto
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'>

```

Could someone please help me with tackling this by figuring out what exactly the error message means and what the problem is? Thank you so much!

---

<div class="post-metadata">

**Author:** ![jeremy.a.gray](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremy.a.gray/32/181458_2.png) [@jeremy.a.gray](https://forum.freecodecamp.org/u/jeremy.a.gray)\
**Post date:** [August 16, 2022, 11:46pm UTC](https://forum.freecodecamp.org/t/page-view-time-series-typeerror-series-to-class-int/543634/2 "2022-08-16T23:46:11Z")

</div>

The error is saying it can’t convert the `df.count()` result to an integer. If you modify the test to print that result and run it on a working project, you’ll see:

```nohighlight
value 1238
dtype: int64

```

which is convertible to integer. Your code is producing

```nohighlight
value 1238
month 1238
year 1238
dtype: int64

```

which is the right value in the wrong format, which means that your data cleaning is working enough for the calculations but just not passing the tests yet. It looks like your cleaned data still has extra columns and `df.count()` is returning the overall length and the length the of columns as well and python can’t convert that series (3 numbers) to an integer (one number) because it can’t know which you want.

---

<div class="post-metadata">

**Author:** ![soupybeanie](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/soupybeanie/32/267892_2.png) [@soupybeanie](https://forum.freecodecamp.org/u/soupybeanie)\
**Post date:** [August 17, 2022, 3:05pm UTC](https://forum.freecodecamp.org/t/page-view-time-series-typeerror-series-to-class-int/543634/3 "2022-08-17T15:05:58Z")

</div>

Umm how do I do that? I tried a bunch of methods but idk how to remove the extra columns and keep only one

---

<div class="post-metadata">

**Author:** ![EdenHimmelB](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/edenhimmelb/32/285718_2.png) [@EdenHimmelB](https://forum.freecodecamp.org/u/EdenHimmelB)\
**Post date:** [October 24, 2022, 2:57pm UTC](https://forum.freecodecamp.org/t/page-view-time-series-typeerror-series-to-class-int/543634/4 "2022-10-24T14:57:48Z")

</div>

This problem can be solved if you modify test\_module line #6 to actual = int(time\_series\_visualizer.df.count(numeric\_only=True)[0]) so that it only takes 1 number as jeremy suggested.

---

<div class="post-metadata">

**Author:** ![jeremy.a.gray](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremy.a.gray/32/181458_2.png) [@jeremy.a.gray](https://forum.freecodecamp.org/u/jeremy.a.gray)\
**Post date:** [October 24, 2022, 10:30pm UTC](https://forum.freecodecamp.org/t/page-view-time-series-typeerror-series-to-class-int/543634/5 "2022-10-24T22:30:05Z")

</div>

Sorry, that’s not what I was suggesting. The test is correct; the original code is wrong and should be modified to pass the test. As I indicated in my example, it’s possible to clean the data in such a way as to not add extra columns which cause the problem with `df.count()`.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [April 25, 2023, 10:30am UTC](https://forum.freecodecamp.org/t/page-view-time-series-typeerror-series-to-class-int/543634/6 "2023-04-25T10:30:28Z")

</div>

Closed on April 25, 2023, 10:30am UTC

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