Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in examples/causal_inference/bayesian_nonparametric_causal.ipynb #724

Open
wd60622 opened this issue Nov 15, 2024 · 0 comments
Open

Comments

@wd60622
Copy link

wd60622 commented Nov 15, 2024

Seems to be some pandas error.

────────────────────────────────── Error running examples/causal_inference/bayesian_nonparametric_causal.ipynb ───────────────────────────────────

---------------------------------------------------------------------------
Exception encountered at "In [17]":
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[17], line 3
      1 temp = X.copy()
      2 temp["ps"] = ps_logit.values
----> 3 temp["ps_cut"] = pd.qcut(temp["ps"], 5)
      6 def plot_balance(temp, col, t):
      7     fig, axs = plt.subplots(1, 5, figsize=(20, 9))

File ~/micromamba/envs/pymc-examples/lib/python3.11/site-packages/pandas/core/reshape/tile.py:340, in qcut(x, q, labels, retbins, precision,
duplicates)
    336 quantiles = np.linspace(0, 1, q + 1) if is_integer(q) else q
    338 bins = x_idx.to_series().dropna().quantile(quantiles)
--> 340 fac, bins = _bins_to_cuts(
    341     x_idx,
    342     Index(bins),
    343     labels=labels,
    344     precision=precision,
    345     include_lowest=True,
    346     duplicates=duplicates,
    347 )
    349 return _postprocess_for_cut(fac, bins, retbins, original)

File ~/micromamba/envs/pymc-examples/lib/python3.11/site-packages/pandas/core/reshape/tile.py:443, in _bins_to_cuts(x_idx, bins, right, labels,
precision, include_lowest, duplicates, ordered)
    441 if len(unique_bins) < len(bins) and len(bins) != 2:
    442     if duplicates == "raise":
--> 443         raise ValueError(
    444             f"Bin edges must be unique: {repr(bins)}.\n"
    445             f"You can drop duplicate edges by setting the 'duplicates' kwarg"
    446         )
    447     bins = unique_bins
    449 side: Literal["left", "right"] = "left" if right else "right"

ValueError: Bin edges must be unique: Index([0.47, 0.48, 0.48, 0.48, 0.49, 0.5], dtype='float64', name='ps').
You can drop duplicate edges by setting the 'duplicates' kwarg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant