AllenDowney / ThinkBayes2

Text and code for the forthcoming second edition of Think Bayes, by Allen Downey.
http://allendowney.github.io/ThinkBayes2/
MIT License
1.8k stars 1.49k forks source link

TypeError: Series.__init__() got an unexpected keyword argument 'normalize' #58

Closed Strigfox85 closed 2 years ago

Strigfox85 commented 2 years ago

Hi, Professor. I am facing this problem when I am practicing probability mass function in gss.hdf5. I am following exactly what have you teach in the slides. May I know why is this happening? Thank you.

import pandas as pd
import matplotlib.pyplot as plt
from empiricaldist import Pmf
gss = pd.read_hdf('gss.hdf5','gss')
educ =gss['educ']
pmf_educ = Pmf(educ normalize=False)

Traceback (most recent call last): File "c:\Users\User\Desktop\Study\Data_Camp\courses\Exploratory Data Analysis in Python\Probability_mass_functions.py", line 30, in pmf_educ = Pmf(educ, normalize=False) File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\empiricaldist\empiricaldist.py", line 45, in init super().init(*args, **kwargs) TypeError: Series.init() got an unexpected keyword argument 'normalize'``

AllenDowney commented 2 years ago

The version of Pmf in empiricaldist is a little different from the version in the DataCamp course. To make a Pmf from a sequence, you need

Pmf.from_seq([1,2,3], normalize=False)

This notebook is the best intro to the API.

https://nbviewer.org/github/AllenDowney/empiricaldist/blob/master/empiricaldist/dist_demo.ipynb

Strigfox85 commented 2 years ago

I see, thank you. Professor.