# Buggy code
def render_cat(
    itmdt: Intermediate, yscale: str, plot_width: int, plot_height: int
) -> Tabs:
    """
    Render plots from plot(df, x) when x is a categorical column
    """
    tabs: List[Panel] = []
    osd = itmdt["statsdata"]
    tabs.append(stats_viz_cat(osd, plot_width, plot_height))
    df, total_grps, miss_pct = itmdt["data"]
    fig = bar_viz(
        df[:-1],
        total_grps,
        miss_pct,
        itmdt["col"],
        yscale,
        plot_width,
        plot_height,
        True,
    )
    tabs.append(Panel(child=row(fig), title="bar chart"))
    tabs.append(pie_viz(df, itmdt["col"], miss_pct, plot_width, plot_height))
    freq_tuple = itmdt["word_cloud"]
    word_cloud = wordcloud_viz(freq_tuple, plot_width, plot_height)
    tabs.append(Panel(child=row(word_cloud), title="word cloud"))
    wordfreq = wordfreq_viz(freq_tuple, plot_width, plot_height, True)
    tabs.append(Panel(child=row(wordfreq), title="words frequency"))
    df, miss_pct = itmdt["length_dist"]
    length_dist = hist_viz(
        df, miss_pct, "length", yscale, plot_width, plot_height, True
    )
    tabs.append(Panel(child=row(length_dist), title="length"))
    tabs = Tabs(tabs=tabs)
    return tabs


# Traceback (ValueError)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-43-f8a3846cc211> in <module>
1 df = pd.DataFrame({"A": ["01-02", "01-02"]})
----> 2 plot(df, "A", top_words=2)

~/dataprep/dataprep/eda/basic/__init__.py in plot(df, x, y, z, bins, ngroups, largest, nsubgroups, timeunit, agg, sample_size, value_range, yscale, tile_size, dtype, top_words, stopword, lemmatize, stem)
163         stem=stem,
164     )
--> 165     figure = render(intermediate, yscale=yscale, tile_size=tile_size)
166
167     return Report(figure)

~/dataprep/dataprep/eda/basic/render.py in render(itmdt, yscale, tile_size, plot_width_sml, plot_height_sml, plot_width_lrg, plot_height_lrg, plot_width_wide)
1684         visual_elem = render_basic(itmdt, yscale, plot_width_sml, plot_height_sml)
1685     elif itmdt.visual_type == "categorical_column":
-> 1686         visual_elem = render_cat(itmdt, yscale, plot_width_lrg, plot_height_lrg)
1687     elif itmdt.visual_type == "numerical_column":
1688         visual_elem = render_num(itmdt, yscale, plot_width_lrg, plot_height_lrg)

~/dataprep/dataprep/eda/basic/render.py in render_cat(itmdt, yscale, plot_width, plot_height)
1393     tabs.append(pie_viz(df, itmdt["col"], miss_pct, plot_width, plot_height))
1394     freq_tuple = itmdt["word_cloud"]
-> 1395     word_cloud = wordcloud_viz(freq_tuple, plot_width, plot_height)
1396     tabs.append(Panel(child=row(word_cloud), title="word cloud"))
1397     wordfreq = wordfreq_viz(freq_tuple, plot_width, plot_height, True)

~/dataprep/dataprep/eda/basic/render.py in wordcloud_viz(freq_tuple, plot_width, plot_height)
228     )
229     top_freq = freq_tuple[1]
--> 230     wordcloud.generate_from_frequencies(dict(top_freq))
231     wcimg = wordcloud.to_array().astype(np.uint8)
232     alpha = np.full([*wcimg.shape[:2], 1], 255, dtype=np.uint8)

~/dataprep/.venv/lib/python3.8/site-packages/wordcloud/wordcloud.py in generate_from_frequencies(self, frequencies, max_font_size)
401         frequencies = sorted(frequencies.items(), key=itemgetter(1), reverse=True)
402         if len(frequencies) <= 0:
--> 403             raise ValueError("We need at least 1 word to plot a word cloud, "
404                              "got %d." % len(frequencies))
405         frequencies = frequencies[:self.max_words]

ValueError: We need at least 1 word to plot a word cloud, got 0.

# Fixed code
def render_cat(
    itmdt: Intermediate, yscale: str, plot_width: int, plot_height: int
) -> Tabs:
    """
    Render plots from plot(df, x) when x is a categorical column
    """
    tabs: List[Panel] = []
    osd = itmdt["statsdata"]
    tabs.append(stats_viz_cat(osd, plot_width, plot_height))
    df, total_grps, miss_pct = itmdt["data"]
    fig = bar_viz(
        df[:-1],
        total_grps,
        miss_pct,
        itmdt["col"],
        yscale,
        plot_width,
        plot_height,
        True,
    )
    tabs.append(Panel(child=row(fig), title="bar chart"))
    tabs.append(pie_viz(df, itmdt["col"], miss_pct, plot_width, plot_height))
    freq_tuple = itmdt["word_cloud"]
    if freq_tuple[0] != 0:
        word_cloud = wordcloud_viz(freq_tuple, plot_width, plot_height)
        tabs.append(Panel(child=row(word_cloud), title="word cloud"))
        wordfreq = wordfreq_viz(freq_tuple, plot_width, plot_height, True)
        tabs.append(Panel(child=row(wordfreq), title="words frequency"))
    df, miss_pct = itmdt["length_dist"]
    length_dist = hist_viz(
        df, miss_pct, "length", yscale, plot_width, plot_height, True
    )
    tabs.append(Panel(child=row(length_dist), title="length"))
    tabs = Tabs(tabs=tabs)

    return tabs