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

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). #5

Closed
ghost opened this issue Jul 10, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Jul 10, 2018

When using a pandas DataFrame, I keep getting this error, no matter what DataFrame I use:

Traceback (most recent call last):
  File "clean_input_file.py", line 177, in <module>
    main()
  File "clean_input_file.py", line 172, in main
    plot_res(data_FSW)
  File "clean_input_file.py", line 149, in plot_res
    title={'label': 'Vote Percentage in 2016 US Presidential Election', 'loc': 'left'}
  File "C:\Users\Pez Amaury\AppData\Local\Programs\Python\Python36-32\lib\site-packages\matplotlib\pyplot.py", line 548, in figure
    **kwargs)
  File "C:\Users\Pez Amaury\AppData\Local\Programs\Python\Python36-32\lib\site-packages\matplotlib\backend_bases.py", line 160, in new_figure_manager
    fig = fig_cls(*args, **kwargs)
  File "C:\Users\Pez Amaury\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pywaffle\waffle.py", line 158, in __init__
    if (not self.fig_args['values'] or not self.fig_args['rows']) and not self.plots:
  File "C:\Users\Pez Amaury\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\generic.py", line 1573, in __nonzero__
    .format(self.__class__.__name__))
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

I understand this is due to using operators or/and in waffle.py, so changing them to np.logical_and and np.logical_or would probably solve the problem.

Here's the dataFrame I'm using:

Variables
ART last 12 months 0.0
Access to condoms last 12 months 0.0
Any STI treatment last 12 months 0.0
Clean needles/syringes at last injection 0.0
Condom use at last time they had sex 0.0
Condom use when had anal sex last time with a male partner 0.0
Condom use when had sex last time with a commercial client 0.0
HBV Prevalence 0.0
HCV Prevalence 0.0
HIV Prevalence 0.0
HIV incidence 0.0
HIV test history 0.0
HIV test in last 12 months 0.0
HIV-1 Prevalence 0.0
HIV-2 Prevalence 0.0
OST/MMT last 6 months 0.0
Other STI Prevalence 0.0
Received HIV test results 0.0
STI test last 12 months 0.0
Syphilis Prevalence 0.0
Name: 2001, dtype: float64

@gyli
Copy link
Owner

gyli commented Jul 11, 2018

Thank you for letting me know this issue!

I have figured out what causes this issue and I will fix it soon.

At current stage, if you want to avoid this error with current version, you can either use parameter "plots" with "111" as the position for the single plot, or convert the pandas series into list or dict.

@gyli
Copy link
Owner

gyli commented Jul 11, 2018

Fixed. Please upgrade to the latest version 0.0.9.

@gyli gyli closed this as completed Jul 11, 2018
@ghost
Copy link
Author

ghost commented Jul 19, 2018

Thank you :)

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