vDataFrame.bar¶
In [ ]:
vDataFrame.bar(columns: list,
method: str = "density",
of: str = "",
max_cardinality: tuple = (6, 6),
h: tuple = (None, None),
hist_type: str = "auto",
ax=None,
**style_kwds,)
Draws the bar chart of the input vcolumns based on an aggregation.
Parameters¶
| Name | Type | Optional | Description |
|---|---|---|---|
columns | list | ❌ | List of the vcolumns names. The list must have one or two elements. |
method | str | ✓ | The method to use to aggregate the data.
|
of | str | ✓ | The vcolumn to use to compute the aggregation. |
h | tuple | ✓ | Interval width of the vcolumns 1 and 2 bars. It is only valid if the vcolumns are numerical. Optimized h will be computed if the parameter is empty or invalid. |
max_cardinality | tuple | ✓ | Maximum number of distinct elements for vcolumns 1 and 2 to be used as categorical (No h will be picked or computed) |
hist_type | str | ✓ | One of the following histogram types:
|
ax | Matplotlib axes object | ✓ | The axes to plot on. |
**style_kwds | any | ✓ | Any optional parameter to pass to the Matplotlib functions. |
In [1]:
from verticapy.datasets import load_titanic
titanic = load_titanic()
display(titanic)
In [3]:
titanic.bar(["survived", "pclass"])
Out[3]:
In [5]:
# Avg of survived partitioned by pclass, sex
titanic.bar(["sex", "pclass"], method = "avg", of = "survived")
Out[5]:
In [7]:
# Stacked : Avg of survived partitioned by pclass, sex
titanic.bar(["sex", "pclass"],
method = "avg",
of = "survived",
hist_type = "stacked")
Out[7]:
In [9]:
# Fully Stacked
titanic.bar(["sex", "pclass"],
method = "density",
hist_type = "fully_stacked")
Out[9]:
In [12]:
# Pyramid
titanic.bar(["sex", "age"],
method = "density",
hist_type = "pyramid")
Out[12]:
In [10]:
# Avg of survived partitioned by age, fare
# age will be discretized using an interval of 30 years
# fare will be discretized using an interval of 150£
titanic.bar(["age", "fare"],
method = "avg",
of = "survived",
h = (30, 150))
Out[10]:
See Also¶
| vDataFrame.boxplot | Draws the Box Plot of the input vcolumns. |
| vDataFrame.hist | Draws the Histogram of the input vcolumns based on an aggregation. |
| vDataFrame.pivot_table | Draws the Pivot Table of vcolumns based on an aggregation. |
