क्या मौसम गिरफ्तारी दर को प्रभावित करता है?

pandas के साथ Police Activity का विश्लेषण

Kevin Markham

Founder, Data School

ड्राइवर जेंडर और वाहन सर्च

ri.search_conducted.mean()
0.0382153092354627
ri.groupby('driver_gender').search_conducted.mean()
driver_gender
F    0.019181
M    0.045426
pandas के साथ Police Activity का विश्लेषण
ri.groupby(['violation', 'driver_gender']).search_conducted.mean()
violation            driver_gender
Equipment            F                0.039984
                     M                0.071496
Moving violation     F                0.039257
                     M                0.061524
Other                F                0.041018
                     M                0.046191
Registration/plates  F                0.054924
                     M                0.108802
Seat belt            F                0.017301
                     M                0.035119
Speeding             F                0.008309
                     M                0.027885
pandas के साथ Police Activity का विश्लेषण
search_rate = ri.groupby(['violation',
                          'driver_gender']).search_conducted.mean()

search_rate
violation          driver_gender
Equipment          F               0.039984
                   M               0.071496
Moving violation   F               0.039257
                   M               0.061524
...                ...                  ...
type(search_rate)

type(search_rate.index)
pandas.core.series.Series

pandas.core.indexes.multi.MultiIndex
pandas के साथ Police Activity का विश्लेषण
violation          driver_gender
Equipment          F               0.039984
                   M               0.071496
Moving violation   F               0.039257
                   M               0.061524
...                ...                  ...
search_rate.loc['Equipment']
driver_gender
F    0.039984
M    0.071496
search_rate.loc['Equipment', 'M']
0.07149643705463182
pandas के साथ Police Activity का विश्लेषण

मल्टी-इंडेक्सड Series को DataFrame में बदलना

search_rate.unstack()
driver_gender             F         M
violation
Equipment          0.039984  0.071496
Moving violation   0.039257  0.061524
Other              0.041018  0.046191
...                     ...       ...
type(search_rate.unstack())
pandas.core.frame.DataFrame
pandas के साथ Police Activity का विश्लेषण

मल्टी-इंडेक्सड Series को DataFrame में बदलना

ri.pivot_table(index='violation',
               columns='driver_gender',
               values='search_conducted')
driver_gender             F         M
violation
Equipment          0.039984  0.071496
Moving violation   0.039257  0.061524
Other              0.041018  0.046191
...                     ...       ...
pandas के साथ Police Activity का विश्लेषण

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

pandas के साथ Police Activity का विश्लेषण

Preparing Video For Download...