Categorical डेटा का विज़ुअलाइज़ेशन

Bokeh के साथ इंटरएक्टिव डेटा विज़ुअलाइज़ेशन

George Boorman

Core Curriculum Manager, DataCamp

Categorical डेटा

  • Categorical डेटा वह डेटा है जिसके विकल्प/लेबल तय होते हैं.

    • उदाहरण: gender या जन्म का देश.
  • Factors, categorical वैरिएबल्स के लिए एक और शब्द है

print(nba[["position", "team", "conference"]].head())
    position    team    conference
0   PG          OKC     West
1   PG          HOU     West
2   PG          BOS     East
3   C           NO      West
4   SG          TOR     East
Bokeh के साथ इंटरएक्टिव डेटा विज़ुअलाइज़ेशन

Sorting

बिना सॉर्ट का बारप्लॉट

pos = nba.groupby("position")["points"].mean()
pos = pos.sort_values("points", ascending=False)

fig = figure(x_range=pos["position"], x_axis_label="Position", y_axis_label="Points per Game") fig.vbar(x=pos["position"], top=pos["points"]) output_file(filename="sorted_plot.html") show(fig)

सॉर्ट किया हुआ बारप्लॉट

Bokeh के साथ इंटरएक्टिव डेटा विज़ुअलाइज़ेशन

Padding

fig = figure(x_range=nba["position"], 
             x_axis_label="Position", 
             y_axis_label="Points per Game")
fig.vbar(x=nba["position"], top=nba["points"],

width=0.9)
output_file(filename="padded_plot.html") show(fig)

पैडेड सॉर्टेड बारप्लॉट

Bokeh के साथ इंटरएक्टिव डेटा विज़ुअलाइज़ेशन

Orientation

fig = figure(x_range=nba['position'], 
             x_axis_label="Position", 
             y_axis_label="Points per Game")
fig.vbar(x=nba["position"], top=nba["points"], width=0.9)

fig.xaxis.major_label_orientation = 45
output_file(filename="rotated_x_label_plot.html") show(fig)
Bokeh के साथ इंटरएक्टिव डेटा विज़ुअलाइज़ेशन

Rotated x-axis labels

घुमाए हुए x-अक्ष लेबल

Bokeh के साथ इंटरएक्टिव डेटा विज़ुअलाइज़ेशन

Nested श्रेणियाँ

positions = ["Point Guard", "Shooting Guard", 
            "Small Forward", "Power Forward", "Center"]
conferences = ["East", "West"]

factors = [("Point Guard", "East"), ("Point Guard", "West"), ("Shooting Guard", "East"), ("Shooting Guard", "West"), ("Small Forward", "East"), ("Small Forward", "West"), ("Power Forward", "East"), ("Power Forward", "West"), ("Center", "East"), ("Center", "West")]
Bokeh के साथ इंटरएक्टिव डेटा विज़ुअलाइज़ेशन

Grouped bar plot बनाना

from bokeh.models import FactorRange

fig = figure(x_range=FactorRange(*factors), y_axis_label="Points per Game")
fig.vbar(x=factors, top=nba["points"], width=0.9)
output_file(filename="grouped_bar_plot.html") show(fig)
Bokeh के साथ इंटरएक्टिव डेटा विज़ुअलाइज़ेशन

Grouped bar plot

ग्रुप्ड बारप्लॉट

Bokeh के साथ इंटरएक्टिव डेटा विज़ुअलाइज़ेशन

अभ्यास करते हैं!

Bokeh के साथ इंटरएक्टिव डेटा विज़ुअलाइज़ेशन

Preparing Video For Download...