Exploring Binary and Categorical Data¶
In [1]:
Copied!
import pandas as pd
import pandas as pd
In [2]:
Copied!
data = pd.read_csv("../data/dfw_airline.csv")
data
data = pd.read_csv("../data/dfw_airline.csv")
data
Out[2]:
| Carrier | ATC | Weather | Security | Inbound | |
|---|---|---|---|---|---|
| 0 | 64263.16 | 84856.5 | 11235.42 | 343.15 | 118427.82 |
In [3]:
Copied!
flight = data.transpose()
flight.plot.bar(legend=False, figsize=(4,4))
flight = data.transpose()
flight.plot.bar(legend=False, figsize=(4,4))
Out[3]:
<Axes: >
In [4]:
Copied!
flight_with_melt = data.melt(var_name="Cause", value_name="Count")
flight_with_melt.sort_values("Count", ascending=False, inplace=True)
flight_with_melt = data.melt(var_name="Cause", value_name="Count")
flight_with_melt.sort_values("Count", ascending=False, inplace=True)
In [5]:
Copied!
flight_with_melt.plot.bar(x="Cause", y="Count", legend=True, figsize=(4,4))
flight_with_melt.plot.bar(x="Cause", y="Count", legend=True, figsize=(4,4))
Out[5]:
<Axes: xlabel='Cause'>
We can see that the mode of the cause of deleay for this dataset is Inbound.