Waterfall Chart Python || Lesson 3.10 || Python for Data Science || Learning Monkey ||
Waterfall Chart Python
In this class, We discuss Waterfall Chart Python.
Waterfall Chart
To construct a waterfall chart in python, we need to install the module waterfallcharts.
Command to install waterfall charts pip install waterfallcharts.
Waterfall charts are used to identify a cumulative effect of a variable over time.
In our superstore data set, we can apply the waterfall model on monthly profits. Learn superstore data set. Click here.
In our example, we use subcategories and profit to display the waterfall plot.
Example
The below program shows the waterfall plot for subcategories and profit.
import pandas as pd
import numpy as np
import waterfall_chart
import matplotlib.pyplot as plt
import pandas as pd
df=pd.read_excel('sampledata.xls',sheet_name='Orders')
print(df.head())
temp=pd.DataFrame(df.groupby(['Sub-Category']).agg({'Profit':'sum'}))
print(temp)
x=temp.index
y=temp['Profit'].values
z=plt.figure()
plt.rcParams["figure.figsize"] = (10,6)
plt.rcParams["figure.facecolor"]="yellow"
waterfall_chart.plot(x, y,)
plt.xticks(rotation=90)
plt.show()
First, understand the waterfall chart. Then we understand the code.
In the output, we have a subcategory on the x-axis. And Profits on the y-axis.
The cumulative effect of the profit for each subcategory is shown.
The last bar is showing the total profit. And it is given the name net.
For better practice, the reader should apply the waterfall model on month and profit.
In our previous classes, we discussed taking a month and year from the date.
In the above program, we use rcparams to define the figure size and color. Click here.
net_label and rotation_value
We use the parameter net_label to change the name of the last bar.
We use the rotation_value parameter to rotate the x-axis labels.
The below examples show the program using net_label and rotation_value parameters.
# net label and rotation
z=plt.figure()
plt.rcParams["figure.figsize"] = (10,6)
plt.rcParams["figure.facecolor"]="yellow"
waterfall_chart.plot(x, y,net_label='Total',rotation_value=90)
plt.show()
sorted_value
We use the parameter sorted_value to arrange the profits in the sorted order.
sorted_value parameter will consider the value to sort the profits.
The below example shows the program to display profits in descending order.
z=plt.figure()
plt.rcParams["figure.figsize"] = (10,6)
plt.rcParams["figure.facecolor"]="yellow"
waterfall_chart.plot(x, y,net_label='Total',rotation_value=90,sorted_value=True)
plt.show()
Link for playlists:
https://www.youtube.com/channel/UCl8x4Pn9Mnh_C1fue-Yndig/playlists
Link for our website: https://learningmonkey.in
Follow us on Facebook @ https://www.facebook.com/learningmonkey
Follow us on Instagram @ https://www.instagram.com/learningmonkey1/
Follow us on Twitter @ https://twitter.com/_learningmonkey
Mail us @ [email protected]
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Waterfall Chart Python || Lesson 3.10 || Python for Data Science || Learning Monkey ||», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.