Skip to content

Commit fb941c3

Browse files
authored
Merge pull request statsmodels#9683 from bashtage/fix-notebooks
DOC: Fix issues affecting notebooks
2 parents 1fbab87 + 3e5d76b commit fb941c3

File tree

6 files changed

+16
-12
lines changed

6 files changed

+16
-12
lines changed

examples/notebooks/gee_score_test_simulation.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
"import matplotlib.pyplot as plt\n",
2323
"import numpy as np\n",
2424
"import pandas as pd\n",
25-
"import statsmodels.api as sm\n",
26-
"from scipy.stats.distributions import norm, poisson"
25+
"from scipy.stats.distributions import norm, poisson\n",
26+
"\n",
27+
"import statsmodels.api as sm"
2728
]
2829
},
2930
{

examples/notebooks/kernel_density.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@
3232
"%matplotlib inline\n",
3333
"import matplotlib.pyplot as plt\n",
3434
"import numpy as np\n",
35-
"import statsmodels.api as sm\n",
3635
"from scipy import stats\n",
36+
"\n",
37+
"import statsmodels.api as sm\n",
3738
"from statsmodels.distributions.mixture_rvs import mixture_rvs"
3839
]
3940
},

examples/notebooks/mstl_decomposition.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
"metadata": {},
3232
"outputs": [],
3333
"source": [
34-
"import matplotlib.pyplot as plt\n",
3534
"import datetime\n",
36-
"import pandas as pd\n",
35+
"\n",
36+
"import matplotlib.pyplot as plt\n",
3737
"import numpy as np\n",
38+
"import pandas as pd\n",
3839
"import seaborn as sns\n",
3940
"from pandas.plotting import register_matplotlib_converters\n",
4041
"\n",
41-
"from statsmodels.tsa.seasonal import MSTL\n",
42-
"from statsmodels.tsa.seasonal import DecomposeResult\n",
42+
"from statsmodels.tsa.seasonal import MSTL, DecomposeResult\n",
4343
"\n",
4444
"register_matplotlib_converters()\n",
4545
"sns.set_style(\"darkgrid\")"
@@ -92,7 +92,7 @@
9292
"weekly_seasonality = 10 * np.sin(2 * np.pi * t / (24 * 7))\n",
9393
"trend = 0.0001 * t**2\n",
9494
"y = trend + daily_seasonality + weekly_seasonality + np.random.randn(len(t))\n",
95-
"ts = pd.date_range(start=\"2020-01-01\", freq=\"H\", periods=len(t))\n",
95+
"ts = pd.date_range(start=\"2020-01-01\", freq=\"h\", periods=len(t))\n",
9696
"df = pd.DataFrame(data=y, index=ts, columns=[\"y\"])"
9797
]
9898
},
@@ -323,7 +323,7 @@
323323
"timeseries = timeseries[mask]\n",
324324
"\n",
325325
"# Resample to hourly\n",
326-
"timeseries = timeseries.set_index(\"ds\").resample(\"H\").sum()\n",
326+
"timeseries = timeseries.set_index(\"ds\").resample(\"h\").sum()\n",
327327
"timeseries.head()"
328328
]
329329
},
@@ -478,7 +478,7 @@
478478
],
479479
"metadata": {
480480
"kernelspec": {
481-
"display_name": "Python 3",
481+
"display_name": "Python 3 (ipykernel)",
482482
"language": "python",
483483
"name": "python3"
484484
},
@@ -492,7 +492,7 @@
492492
"name": "python",
493493
"nbconvert_exporter": "python",
494494
"pygments_lexer": "ipython3",
495-
"version": "3.8.7"
495+
"version": "3.12.9"
496496
}
497497
},
498498
"nbformat": 4,

examples/notebooks/rolling_ls.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"import pandas as pd\n",
3434
"import pandas_datareader as pdr\n",
3535
"import seaborn\n",
36+
"\n",
3637
"import statsmodels.api as sm\n",
3738
"from statsmodels.regression.rolling import RollingOLS\n",
3839
"\n",

examples/notebooks/variance_components.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"source": [
1919
"import numpy as np\n",
2020
"import pandas as pd\n",
21+
"\n",
2122
"import statsmodels.api as sm\n",
2223
"from statsmodels.regression.mixed_linear_model import VCSpec"
2324
]

statsmodels/nonparametric/kde.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def entropy(self):
265265

266266
def entr(x, s):
267267
pdf = kern.density(s, x)
268-
return pdf * np.log(pdf + 1e-12)
268+
return np.squeeze(pdf * np.log(pdf + 1e-12))
269269

270270
kern = self.kernel
271271

0 commit comments

Comments
 (0)