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

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

Kevin Markham

Founder, Data School

Datetime डेटा का विश्लेषण

apple
    price    volume       date_and_time
0  174.35  20567800 2018-01-08 16:00:00
1  174.33  21584000 2018-01-09 16:00:00
2  155.15  54390500 2018-02-08 16:00:00
3  156.41  70672600 2018-02-09 16:00:00
4  176.94  23774100 2018-03-08 16:00:00
5  179.98  32185200 2018-03-09 16:00:00
pandas के साथ Police Activity का विश्लेषण

Datetime गुण एक्सेस करना (1)

apple.dtypes
price                   float64
volume                    int64
date_and_time    datetime64[ns]
apple.date_and_time.dt.month
0    1
1    1
2    2
3    2
...
pandas के साथ Police Activity का विश्लेषण

Datetime गुण एक्सेस करना (2)

apple.set_index('date_and_time', inplace=True)

apple.index
DatetimeIndex(['2018-01-08 16:00:00', '2018-01-09 16:00:00',
               '2018-02-08 16:00:00', '2018-02-09 16:00:00',
               '2018-03-08 16:00:00', '2018-03-09 16:00:00'],
              dtype='datetime64[ns]', name='date_and_time', freq=None)
apple.index.month
Int64Index([1, 1, 2, 2, 3, 3], dtype='int64', name='date_and_time')
  • DatetimeIndex के साथ dt accessor का उपयोग नहीं होता है
pandas के साथ Police Activity का विश्लेषण

मासिक औसत कीमत निकालना

apple.price.mean()
169.52666666666667
apple.groupby(apple.index.month).price.mean()
date_and_time
1    174.34
2    155.78
3    178.46
Name: price, dtype: float64
monthly_price = apple.groupby(apple.index.month).price.mean()
pandas के साथ Police Activity का विश्लेषण

मासिक औसत कीमत का प्लॉट बनाना

import matplotlib.pyplot as plt
monthly_price.plot()
  • लाइन प्लॉट: x-अक्ष पर Series index, y-अक्ष पर Series values
plt.xlabel('Month')
plt.ylabel('Price')
plt.title('Monthly mean stock price for Apple')
plt.show()
pandas के साथ Police Activity का विश्लेषण

एप्पल के मासिक औसत स्टॉक प्राइस का लाइन प्लॉट

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

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

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

Preparing Video For Download...