Kdeplot
A kdeplot
plot is a method for visualizing the distribution of observations in a dataset analogous to a histogram. KDE represents the data using a continuous probability density curve in one or more dimensions.















Aufgabe
Swipe to start coding
- Create the kdeplot using the
seaborn
library:
- Set the
x
parameter equals the'max_temp'
; - Set the
hue
parameter equals the'month'
; - Set the
multiple
parameter equals the'stack'
; - Disable the
legend
; - Add the filling;
- Set the data;
- Display the plot.
Lösung
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import warnings
# Ignore all warnings
warnings.filterwarnings('ignore')
# Importing libraries needed
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# Reading the file
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/66ba0c8e-8422-413c-b7e1-74bd24c61656/weather+upd.csv')
# Setting the style
sns.set_style('ticks', {'figure.facecolor' : 'lightcyan'})
# Create a kdeplot
sns.kdeplot(# Set the x
x = 'max_temp',
# Set the hue
hue = 'month',
# Set the multiple
multiple = 'stack',
# Disable the legend
legend = False,
# Add the filling
fill = True,
# Set the data
data = df)
# Display the plot
plt.show()
War alles klar?
Danke für Ihr Feedback!
Abschnitt 2. Kapitel 2
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import warnings
# Ignore all warnings
warnings.filterwarnings('ignore')
# Importing libraries needed
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# Reading the file
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/66ba0c8e-8422-413c-b7e1-74bd24c61656/weather+upd.csv')
# Setting the style
sns.set_style('ticks', {'figure.facecolor' : 'lightcyan'})
# Create a kdeplot
___(# Set the x
___,
# Set the hue
hue = ___,
# Set the multiple
multiple = ___,
# Disable the legend
___,
# Add the filling
___ = True,
# Set the data
___)
# Display the plot
___
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen