I want to know why my function is returning a None Type. I can't seem to find any answers on this and I'm fairly new to Python. I want to be able to use the values from this in calculations and in plotting a histogram. My code is as follows:
def mean_calc_d(data_col):
mean_vals = df[data_col].value_counts().keys().tolist()
mean_counts = df[data_col].value_counts().tolist()
mean_dict = dict(zip(mean_vals, mean_counts))
print(mean_dict)
mean_calc_d("month")
The output I get is a nice dictionary:
{'aug': 184, 'sep': 172, 'mar': 54, 'jul': 32, 'feb': 20, 'jun': 17, 'oct': 15, 'dec': 9, 'apr': 9, 'jan': 2, 'may': 2, 'nov': 1`}
Just as an aside, before that, I call in the csv using this code:
dataframe = pd.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/forest-fires/forestfires.csv')
df = dataframe #I do this to make a copy in case I destroy any elements inadvertantly
The problem I run into is that my function, if I check the type, it says it is a None Type, which means I can't use any of the values to calculate anything else beyond the output I'm getting because it is a None Type. The frequent error I get is:
TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'
What am I doing wrong? Why am I getting it returning as a None Type? I am fairly new to this and I couldn't seem to find an adequate answer in other threads.
Thanks in advance for your help!