Gets a dataframe with several of numeric columns and creates plot that compares the smooth density curves of every selected column.
The short and simple code allows a comparison between the smooth density of a large number of columns. Each density is displayed in a different color and conveniently. The code is very simple to run and all you have to do is import it (instructions below). example of one output:
The code uses the following libraries in Python:
matplotlib
seaborn
pandas
An application of the code is attached to this page under the name:
"implementation.ipynb" the examples outputs are also attached here.
To use this code, you just need to import it as follows:
# import
from multi_density import create_multi_density
from pandas import read_csv
# define variables
data = read_excel(r'path\file.csv')
fields=['a','b','c','d','e','f','g']
names ="my_plot" # you not need to add ".png"
# application
create_multi_density(data,fields,names)
When the variables displayed are:
data: pandas dataframe object.
field: simple list that contain strings. each one of them is column name inside "data" that you want to display its smooth density.
name: string which represents the filename of the GIF you want to save
MIT © Etzion Harari