क्या खोज के दौरान किसे तलाशी दी गई, उस पर gender का असर है?

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

Kevin Markham

Founder, Data School

ri.search_conducted.value_counts()
False    83229
True      3307
ri.search_type.value_counts(dropna=False)
NaN                               83229
Incident to Arrest                 1290
Probable Cause                      924
Inventory                           219
Reasonable Suspicion                214
Protective Frisk                    164
Incident to Arrest,Inventory        123
...
  • .value_counts() डिफॉल्ट रूप से missing values हटाता है
  • dropna=False missing values दिखाता है
pandas के साथ Police Activity का विश्लेषण

Search types की जाँच

ri.search_type.value_counts()
Incident to Arrest                           1290
Probable Cause                                924
Inventory                                     219
Reasonable Suspicion                          214
Protective Frisk                              164
Incident to Arrest,Inventory                  123
Incident to Arrest,Probable Cause             100
...
  • एक से अधिक मान comma से अलग होते हैं
  • 219 searches जिनमें "Inventory" अकेला search type था
  • कई search types में "Inventory" को ढूँढें
pandas के साथ Police Activity का विश्लेषण

किसी string को खोजना (1)

ri['inventory'] = ri.search_type.str.contains('Inventory', na=False)
  • str.contains() string मिलने पर True, नहीं मिलने पर False देता है
  • na=False missing value पर False लौटाता है
pandas के साथ Police Activity का विश्लेषण

किसी string को खोजना (2)

ri.inventory.dtype
dtype('bool')
  • True मतलब inventory हुई, False मतलब नहीं हुई
ri.inventory.sum()
441
pandas के साथ Police Activity का विश्लेषण

Inventory rate की गणना

ri.inventory.mean()
0.0050961449570121106
  • सभी traffic stops में से 0.5% inventory पर खत्म हुए
searched = ri[ri.search_conducted == True]
searched.inventory.mean()
0.13335349259147264
  • searches में से 13.3% में inventory शामिल थी
pandas के साथ Police Activity का विश्लेषण

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

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

Preparing Video For Download...