Fitting a pandas dataframe to a Poisson Distribution
I have a simple dataframe df2 that consist of indices and one column of values. I want to fit this dataframe to a poisson distribution. Below is the code I am using:
import numpy as np
from scipy.optimize import curve_fit
data=df2.values
bins=df2.index
def poisson(k, lamb):
return (lamb^k/ np.math.factorial(k)) * np.exp(-lamb)
params, cov = curve_fit(poisson, np.array(bins.tolist()), data.flatten())
I get the following error:
TypeError: only size-1 arrays can be converted to Python scalars
Topic historgram probability scipy
Category Data Science