lux-org/lux

ValueError: cannot specify integer `bins` when input data contains infinity [BUG]

flppgg opened this issue · 2 comments

Trying to open a dataframe from a .csv that contains numpy.inf values fails with this error:

import lux, pandas
df = pandas.read_csv('filepath')
C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\IPython\core\formatters.py:918: UserWarning:
Unexpected error in rendering Lux widget and recommendations. Falling back to Pandas display.
Please report the following issue on Github: https://github.com/lux-org/lux/issues 

C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\lux\core\frame.py:632: UserWarning:Traceback (most recent call last):
  File "C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\lux\core\frame.py", line 594, in _ipython_display_
    self.maintain_recs()
  File "C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\lux\core\frame.py", line 436, in maintain_recs
    custom_action_collection = custom_actions(rec_df)
  File "C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\lux\action\custom.py", line 76, in custom_actions
    recommendation = lux.config.actions[action_name].action(ldf)
  File "C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\lux\action\correlation.py", line 50, in correlation
    vlist = VisList(intent, ldf)
  File "C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\lux\vis\VisList.py", line 43, in __init__
    self.refresh_source(self._source)
  File "C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\lux\vis\VisList.py", line 336, in refresh_source
    lux.config.executor.execute(self._collection, ldf, approx=approx)
  File "C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\lux\executor\PandasExecutor.py", line 146, in execute
    PandasExecutor.execute_2D_binning(vis)
  File "C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\lux\executor\PandasExecutor.py", line 387, in execute_2D_binning
    vis._vis_data["xBin"] = pd.cut(vis._vis_data[x_attr], bins=lux.config.heatmap_bin_size)
  File "C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\pandas\core\reshape\tile.py", line 244, in cut
    "cannot specify integer `bins` when input data contains infinity"
ValueError: cannot specify integer `bins` when input data contains infinity

simply setting
pandas.set_option('mode.use_inf_as_na', True)
solves the issue for the user, but I don't know how this can be solved in lux

Thanks @flppgg! It looks like this issue comes up when we try to plot a binned histogram when the data contains inf. We'll look into fixing this issue!