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
Please indicate the following details about the environment in which you found the bug:
Copulas version: 0.5.1
Python version: 3.8.5
Operating System: MacOS
Error Description
Is the Gumbel copula meant to be for fitting?The following code gives an error
Steps to reproduce
from copulas.datasets import sample_bivariate_age_income
data = sample_bivariate_age_income()
data.head()
from copulas.bivariate import Gumbel
dist=Gumbel()
dist.fit(data)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-13-a3e24cdf02c2> in <module>
4 from copulas.bivariate import Gumbel
5 dist=Gumbel()
----> 6 dist.fit(data)
~/opt/anaconda3/lib/python3.8/site-packages/copulas/bivariate/base.py in fit(self, X)
174 None
175 """
--> 176 U, V = split_matrix(X)
177 self.check_marginal(U)
178 self.check_marginal(V)
~/opt/anaconda3/lib/python3.8/site-packages/copulas/bivariate/utils.py in split_matrix(X)
13 """
14 if len(X):
---> 15 return X[:, 0], X[:, 1]
16
17 return np.array([]), np.array([])
~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py in __getitem__(self, key)
2900 if self.columns.nlevels > 1:
2901 return self._getitem_multilevel(key)
-> 2902 indexer = self.columns.get_loc(key)
2903 if is_integer(indexer):
2904 indexer = [indexer]
~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2893 casted_key = self._maybe_cast_indexer(key)
2894 try:
-> 2895 return self._engine.get_loc(casted_key)
2896 except KeyError as err:
2897 raise KeyError(key) from err
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
TypeError: '(slice(None, None, None), 0)' is an invalid key
The text was updated successfully, but these errors were encountered:
@siddharthfcb
Hello. I've got the same problem and found an ad-hoc approach to solve it. Hope this would be helpful.
The issue seems to arise due to an invalid slice manipulation to pandas objects, i.e., X[:, 0] is not allowed when X is a pandas object. So, a quick fix is to replace the code with X.iloc[:, 0] but this is not enough because X can be a numpy object when using some other functions such as sample().
So, replacing the code in utils.py with the following could be a quick fix: if len(X): if 'iloc' in dir(X): return X.iloc[:, 0], X.iloc[:, 1] else: return X[:, 0], X[:, 1]
@siddharthfcb Hello. I've got the same problem and found an ad-hoc approach to solve it. Hope this would be helpful.
The issue seems to arise due to an invalid slice manipulation to pandas objects, i.e., X[:, 0] is not allowed when X is a pandas object. So, a quick fix is to replace the code with X.iloc[:, 0] but this is not enough because X can be a numpy object when using some other functions such as sample().
So, replacing the code in utils.py with the following could be a quick fix: if len(X): if 'iloc' in dir(X): return X.iloc[:, 0], X.iloc[:, 1] else: return X[:, 0], X[:, 1]
Environment Details
Please indicate the following details about the environment in which you found the bug:
Error Description
Is the Gumbel copula meant to be for fitting?The following code gives an error
Steps to reproduce
from copulas.datasets import sample_bivariate_age_income
data = sample_bivariate_age_income()
data.head()
from copulas.bivariate import Gumbel
dist=Gumbel()
dist.fit(data)
The text was updated successfully, but these errors were encountered: