source
value_counts
value_counts (data, dropna=False, show_top=10, sort_others=False,
title=None, style=True, width=900, height=650,
colorscale='cividis')
Count the values of data
and return a table of counts (absolute, cumulative, percentage, and cumulative percentage).
data
list, tuple, pandas.Series, pandas.DataFrame
A collection of items to count, using any of the above data structures.
dropna
bool
False
Wether or not to drop missing values.
show_top
int
10
How many top items to show. All remaining items, will be grouped into “Others:”.
sort_others
bool
False
Whether or not to put “Others” in their sorted order. The default is to have this item at the bottom.
title
NoneType
None
The title of the chart.
style
bool
True
Whether or not to style the resulting table with a heatmap.
width
int
900
The width in pixels of the resulting figure. Set this to None to make it use the widthe of its container.
height
int
650
The width in pixels of the resulting figure. Set this to None to make it use the widthe of its container.
colorscale
str
cividis
Which color scale to use for the heatmaps.
Returns
plotly.graph_objects.Figure
Get URL data and count values
apple = pd.read_csv('data/apple_url_list.csv' )
urldf = adv.url_to_df(apple['url' ])
urldf.head()
0
https://www.apple.com/ae/shop/accessories/all
https
www.apple.com
/ae/shop/accessories/all
NaN
NaN
ae
shop
accessories
all
...
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
1
https://www.apple.com/ae/shop/accessories/all/...
https
www.apple.com
/ae/shop/accessories/all/accessibility
NaN
NaN
ae
shop
accessories
all
...
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
2
https://www.apple.com/ae/shop/accessories/all/...
https
www.apple.com
/ae/shop/accessories/all/airtag
NaN
NaN
ae
shop
accessories
all
...
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
3
https://www.apple.com/ae/shop/accessories/all/...
https
www.apple.com
/ae/shop/accessories/all/beats
NaN
NaN
ae
shop
accessories
all
...
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
4
https://www.apple.com/ae/shop/accessories/all/...
https
www.apple.com
/ae/shop/accessories/all/beats-featured
NaN
NaN
ae
shop
accessories
all
...
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
5 rows × 28 columns
Default behavior for a single column
value_counts(urldf['dir_1' ])
Count unique row combinations in more than one column
Setting width=None
will make the width responsive and takes on the width of the chart’s container.
value_counts(urldf[['dir_1' , 'dir_2' ]], width= None )
Filter for a better overview and change colorscale
value_counts(urldf[urldf['dir_1' ].eq('shop' )]['dir_2' ], colorscale= 'magma' )