Repository navigation
Description
Describe the bug
DescrStatsW.quantile throws an error when the inputs contain one element.
TypeError: len() of unsized object
This seems to happen because the weights array is squeezed to a zero-dimensional scalar when it contains only a single value.
This occurred while I was performing a groupby/apply operation on a pandas dataframe in which the groups may contain one or more rows.
I will submit a PR with a fix and a simple test for the issue.
Code Sample, a copy-pastable example if possible
from statsmodels.stats.weightstats import DescrStatsW
x1 = [1]
w1 = [1]
d1 = DescrStatsW(x1, w1)
assert (d1.quantile([0.0, 0.5, 1.0]) == 1).all()Details
Note: As you can see, there are many issues on our GitHub tracker, so it is very possible that your issue has been posted before. Please check first before submitting so that we do not have to handle and close duplicates.
Note: Please be sure you are using the latest released version of statsmodels, or a recent build of master. If your problem has been fixed in an unreleased version, you might be able to use master until a new release occurs.
Note: If you are using a released version, have you verified that the bug exists in the master branch of this repository? It helps the limited resources if we know problems exist in the current master so that they do not need to check whether the code sample produces a bug in the next release.
If the issue has not been resolved, please file it in the issue tracker.
Expected Output
A clear and concise description of what you expected to happen.
Output of import statsmodels.api as sm; sm.show_versions()
Details
[paste the output of import statsmodels.api as sm; sm.show_versions() here below this line]
ImportError: cannot import name '_initialization' from 'statsmodels.tsa.statespace' (/home/brl0/repos/statsmodels/statsmodels/tsa/statespace/__init__.py)
Activity
josef-pkt commentedon Sep 19, 2020
duplicate of #4282
but we leave it open to fix this soon
josef-pkt commentedon Jan 21, 2021
fixed in #7230 which is rebased #7047