Data Analysis and Visualization with Python – Example 5

Comparison of Budget and Actual Sales / Jan 21 – Jun 21


1) Budget Sales VS Actual Sales – Graph (line)

2) Budget Sales sum

3) Actual Sales sum

4) Difference between Budget Sales sum and Actual Sales sum – Euro

5) Actual Sales sum is X % of Budget Sales sum

6) Creation of new data source file (format : csv) with 2 new columns

7) Budget Sales VS Actual Sales – Graph (bar)

Photo 1

8) Budget Sales VS Actual Sales – Graph (line), selection of certain columns to plot and different graph dimensions (photo 1)

9) Budget Sales mean (photo 1)

10) Actual Sales mean (photo 1)

Click the html file data_visualization_with_python_5 to view the project . . .


Data source file : sample_data_sales.csv

Columns in data source file : month, budget_sales, actual_sales


New data source file : sample_data_sales_with_difference.csv

New columns calculated and added with python coding in a new data source file :

New column 1 : difference_value (difference between budget_sales and actual_sales)

New column 2 : difference_perc (actual sales is X% of budget_sales)


Columns found in new data source file : month, budget_sales, actual_sales, difference_value, difference_perc


Feel free to download data source sample_data_sales.csv, sample_data_sales_with_difference.csv and the code for this project : data_visualization_with_python_5.rar

The file “data_visualization_with_python_5.rar” contains the code file : “data_visualization_with_python_5.ipynb”.

Data Visualization with Python Ex:5Photo 2

Code for choosing and showing the data from file : sample_data_sales_with_difference.csv and plotting the graph (photo 2)

# code starts here–

# take data for new csv and create dataframe

data = pd.read_csv(“sample_data_sales_with_difference.csv”)


print (“————————————————————————————“)

print (“sample_data_sales_with_difference.csv”, “view all columns”)

print (data)


df3 = pd.DataFrame(data, columns=[“month”, “budget_sales”, “actual_sales”])


print (“————————————————————————————“)

print (“sample_data_sales_with_difference.csv”, “view columns : month, budget_sales, actual_sales”)

print (df3)


# plot the dataframe

import seaborn as sns


df3.plot(x=”month”, y=[“budget_sales”, “actual_sales”], kind=”bar”)


plt.rcParams[“figure.figsize”] = [8.50, 6.50]

plt.rcParams[“figure.autolayout”] = True

plt.xticks(rotation=30, horizontalalignment=”center”)

plt.title(“Sales / Jan 21 – Jun 21”)


plt.ylabel(“Budget and Actual”)

plt.legend([“Budget”, “Actual”])

# print bar graph

# code ends here–


#python #data_visualization #dataanalysis #mindstormGR #softexperia /


Comments are closed.

Pin It

By continuing to use the site, you agree to the use of cookies. / Συνεχίζοντας να χρησιμοποιείτε την ιστοσελίδα, συμφωνείτε με τη χρήση των cookies. more information / περισσότερες πληροφορίες

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.