Data Analysis with Python Projects - Demographic Data Analyzer

My code on this project has resulted in multiple errors like producing a 0.0% answer on replit but the result on jupyter_notebook is correct.
i have been on this for about a week now please I need some help. Below is a link to my project.
HAPPY NEW YEAR FREECODECAMP! and Thank You for all you do.

https://replit.com/@gesiarray/boilerplate-demographic-data-analyzer-3#demographic_data_analyzer.py

Your browser information:

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

Challenge: Data Analysis with Python Projects - Demographic Data Analyzer

Link to the challenge:

Forking and running your repl yields this error:

  File "main.py", line 6, in <module>
    demographic_data_analyzer.calculate_demographic_data()
  File "/home/runner/boilerplate-demographic-data-analyzer-4/demographic_data_analyzer.py", line 54, in calculate_demographic_data
    top_IN_occupation = occupation_total.idxmax()
  File "/home/runner/boilerplate-demographic-data-analyzer-4/venv/lib/python3.8/site-packages/pandas/core/series.py", line 2110, in idxmax
    i = nanops.nanargmax(com.values_from_object(self), skipna=skipna)
  File "/home/runner/boilerplate-demographic-data-analyzer-4/venv/lib/python3.8/site-packages/pandas/core/nanops.py", line 69, in _f
    return f(*args, **kwargs)
  File "/home/runner/boilerplate-demographic-data-analyzer-4/venv/lib/python3.8/site-packages/pandas/core/nanops.py", line 875, in nanargmax
    result = values.argmax(axis)
ValueError: attempt to get argmax of an empty sequence
exit status 1

Backtracking from where the error began in your code:

  File "/home/runner/boilerplate-demographic-data-analyzer-4/demographic_data_analyzer.py", line 54, in calculate_demographic_data
    top_IN_occupation = occupation_total.idxmax()

you should print the culprit, occupation_total, which yields:

Series([], Name: occupation, dtype: int64)

Backtracking another step and printing the previous dataframe:

Empty DataFrame
Columns: [age, workclass, fnlwgt, education, education-num, marital-status, occupation, relationship, race, sex, capital-gain, capital-loss, hours-per-week, native-country, salary]
Index: []

So, you have an empty data frame to start your analysis of Indian occupations and you need to determine why that is the case.

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