fbdesignpro / sweetviz

Visualize and compare datasets, target values and associations, with one line of code.
MIT License
2.93k stars 275 forks source link

formatter gets series instead of float value #105

Open dz0 opened 2 years ago

dz0 commented 2 years ago

hi when using

  File "/home/jurgis/PycharmProjects/debitum-portfolio/notebooks/jurgis/sw_report.py", line 22, in <module>
    my_report = sv.compare([df_A, "A"], [df_B, "B"])
  File "/home/jurgis/anaconda3/envs/debitum-portfolio/lib/python3.8/site-packages/sweetviz/sv_public.py", line 22, in compare
    report = sweetviz.DataframeReport(source, target_feat, compare,
  File "/home/jurgis/anaconda3/envs/debitum-portfolio/lib/python3.8/site-packages/sweetviz/dataframe_report.py", line 256, in __init__
    self._features[f.source.name] = sa.analyze_feature_to_dictionary(f)
  File "/home/jurgis/anaconda3/envs/debitum-portfolio/lib/python3.8/site-packages/sweetviz/series_analyzer.py", line 142, in analyze_feature_to_dictionary
    sweetviz.series_analyzer_text.analyze(to_process, returned_feature_dict)
  File "/home/jurgis/anaconda3/envs/debitum-portfolio/lib/python3.8/site-packages/sweetviz/series_analyzer_text.py", line 50, in analyze
    feature_dict["html_summary"] = sv_html.generate_html_summary_text(feature_dict, compare_dict)
  File "/home/jurgis/anaconda3/envs/debitum-portfolio/lib/python3.8/site-packages/sweetviz/sv_html.py", line 226, in generate_html_summary_text
    output = template.render(feature_dict = feature_dict, compare_dict = compare_dict, \
  File "/home/jurgis/anaconda3/envs/debitum-portfolio/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/home/jurgis/anaconda3/envs/debitum-portfolio/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/home/jurgis/anaconda3/envs/debitum-portfolio/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "/home/jurgis/anaconda3/envs/debitum-portfolio/lib/python3.8/site-packages/sweetviz/templates/feature_summary_text.html", line 25, in top-level template code
    <div class="pair-pos__num dim">{{ rowdata.count_compare.number|fmt_int_limit }}</div>
  File "/home/jurgis/anaconda3/envs/debitum-portfolio/lib/python3.8/site-packages/sweetviz/sv_html_formatters.py", line 16, in fmt_int_limit
    if value > 999999:
  File "/home/jurgis/anaconda3/envs/debitum-portfolio/lib/python3.8/site-packages/pandas/core/generic.py", line 1442, in __nonzero__
    raise ValueError(
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

with debug I see, that fmt_int_limit gets series with single row: datetime in index, and integer in value.

fbdesignpro commented 10 months ago

Apologies for the long delay, is anyone else seeing this? I'd like to update with a fix, but it would be easier with a good test case.

fbdesignpro commented 10 months ago

@dz0 I'm not sure if you remember this ;)

IKosovych commented 10 months ago

@fbdesignpro I have this error

fbdesignpro commented 10 months ago

@IKosovych Thank you; I'll dig deeper. Can you give me any details? Ideally if you have a test case that'd the great but if you could tell me anything about the function being called and the data that would be helpful also.