You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import pandas as pd
import statsmodels.api as sm
data = sm.datasets.co2.load_pandas()
returns
/usr/local/lib/python3.6/site-packages/statsmodels/datasets/co2/data.py in load_pandas()
64 index = pd.DatetimeIndex(start=data.data['date'][0].decode('utf-8'),
65 periods=len(data.data), format='%Y%m%d',
---> 66 freq='W-SAT')
67 dataset = pd.DataFrame(data.data['co2'], index=index, columns=['co2'])
68 #NOTE: this is how I got the missing values in co2.csv
TypeError: __new__() got an unexpected keyword argument 'format'
Fix
Seems pd.DatetimeIndex() has no argument 'format'. My code worked now after deleting the format argument.
The strange thing is this code worked one month ago, when I should have pandas 0.22.0, but I can't find this argument in the pandas documents for this patch as well.
Hi,
I've been getting the same error and I already tried the fix that you mentioned but it doesn't seem to work.
Please let me know if you have any solutions
`def load_pandas():
data = load()
# pandas <= 0.12.0 fails in the to_datetime regex on Python 3
index = pd.DatetimeIndex(start=data.data['date'][0].decode('utf-8'), periods=len(data.data), freq='W-SAT')
dataset = pd.DataFrame(data.data['co2'], index=index, columns=['co2'])
#NOTE: this is how I got the missing values in co2.csv
#new_index = pd.DatetimeIndex(start='1958-3-29', end=index[-1],
freq='W-SAT')
#data.data = dataset.reindex(new_index)
data.data = dataset
return data`
Any kind of help would be appreciated. Thanks in advance.
My statsmodels's version is 0.9.0, however it doesn't work and return the same error.
And I use acbecker's method solved it.
Besides, can I complain about the statsmodels's "api" mode?😂
When I first use this module, I can see the "api" almost everywhere. But when I read the document of module, I can hardly see the "api". So I'm very confused what the difference between "import statsmodel.api as sm; sm.tsa.ARMA", "import statsmodel.tsa.api as smt; smt.ARMA" and "import statsmodel as sm; sm.tsa.arima_model.ARMA". 🙈
After I turn to read the site-packge, I realized they are equality. But now, I think using "api" also make me bit little puzzled. so I prefer to use "from statsmodel.tsa import arima_model as arimapy; arimapy.ARMA".
One advantage of the api, expecially when new to statsmodels is that tab completion already shows what's available. Without api, you need to know the module where a function is officially () located.
() the actual module might be private, or in the sandbox.
For the following configuration I got the same error and also FIXED IT indirectly:
pandas 0.24.2
statsmodels 0.9.0
numpy 1.16.
sm.datasets.co2.load_pandas().data
Error:
---------------------------------------------------------------------------TypeErrorTraceback (mostrecentcalllast)
<ipython-input-17-d6eff66314c5>in<module>---->1sm.datasets.co2.load_pandas().data~/miniconda3/envs/tsa/lib/python3.7/site-packages/statsmodels/datasets/co2/data.pyinload_pandas()
64index=pd.DatetimeIndex(start=data.data['date'][0].decode('utf-8'),
65periods=len(data.data), format='%Y%m%d',
--->66freq='W-SAT')
67dataset=pd.DataFrame(data.data['co2'], index=index, columns=['co2'])
68#NOTE: this is how I got the missing values in co2.csvTypeError: __new__() gotanunexpectedkeywordargument'format'
Activity
harjain99 commentedon Jul 14, 2018
Hi,
I've been getting the same error and I already tried the fix that you mentioned but it doesn't seem to work.
Please let me know if you have any solutions
`def load_pandas():
data = load()
Any kind of help would be appreciated. Thanks in advance.
atodniAr commentedon Jul 24, 2018
Hi @harjain99
Sorry for a late reply. I'm not sure about the error you got. Can you include the error message python returned?
harjain99 commentedon Jul 28, 2018
Hi @atodniAr,
Its the exact same error as you got :(
bashtage commentedon Aug 2, 2018
This is old statsmodels. Please update to 0.9.0.
acbecker commentedon Aug 2, 2018
I can recreate with:
conda 4.5.9 py36_0
python 3.6.5 hc3d631a_2
statsmodels 0.9.0 py36h035aef0_0
pandas 0.23.3 py36h04863e7_0
A quick workaround is
bashtage commentedon Aug 3, 2018
You are right -- it is fixed in master but not in a released version.
Interesting6 commentedon Jan 22, 2019
My statsmodels's version is 0.9.0, however it doesn't work and return the same error.
And I use acbecker's method solved it.
Besides, can I complain about the statsmodels's "api" mode?😂
When I first use this module, I can see the "api" almost everywhere. But when I read the document of module, I can hardly see the "api". So I'm very confused what the difference between "import statsmodel.api as sm; sm.tsa.ARMA", "import statsmodel.tsa.api as smt; smt.ARMA" and "import statsmodel as sm; sm.tsa.arima_model.ARMA". 🙈
After I turn to read the site-packge, I realized they are equality. But now, I think using "api" also make me bit little puzzled. so I prefer to use "from statsmodel.tsa import arima_model as arimapy; arimapy.ARMA".
josef-pkt commentedon Jan 22, 2019
@Interesting6 see http://www.statsmodels.org/devel/importpaths.html
It's too make two different types of working with statsmodels easier.
(I almost never import the
apibecause the import time is too long for repeated restart of the python process during testing, in notebooks or in spyder. But many users want to have everything imported and available at once, which works well during longer interactive sessions.)josef-pkt commentedon Jan 22, 2019
One advantage of the api, expecially when new to statsmodels is that tab completion already shows what's available. Without api, you need to know the module where a function is officially () located.
() the actual module might be private, or in the sandbox.
Interesting6 commentedon Jan 31, 2019
OK. Thank you.
AVI18794 commentedon Feb 11, 2019
I got the same error even my statsmodels version is 0.9.0. Here is the attached screenshot of my code.

Matt-V50 commentedon Feb 27, 2019
please add
in requirements.txt under project directory and install (pycharm will popup some tip)
bhishanpdl commentedon Mar 26, 2019
For the following configuration I got the same error and also FIXED IT indirectly:
Error:
Solution
Use numpy.rec instead of direct pandas:
bashtage commentedon Jul 19, 2019
Fixed. in master.