विशिष्ट टाइम सीरीज फ्रीक्वेंसी के साथ DateTimeIndex से दिन निकालने के लिए, DateTimeIndex.day प्रॉपर्टी का उपयोग करें।
आवश्यक लाइब्रेरी आयात करें
import pandas as pd
DatetimeIndex बनाएं
पीरियड 6 और फ्रीक्वेंसी D (दिन) के साथ DatetimeIndex। टाइमज़ोन Australia/Sydney है:
datetimeindex = pd.date_range('2021-10-20 02:35:55', periods=6, tz='Australia/Sydney', freq='D')
DateTimeIndex प्रदर्शित करें
print("DateTimeIndex...\n", datetimeindex)
दिन प्राप्त करें
print("\nGetting the day..\n", datetimeindex.day)
पूर्ण उदाहरण
import pandas as pd
datetimeindex = pd.date_range('2021-10-20 02:35:55', periods=6, tz='Australia/Sydney', freq='D')
print("DateTimeIndex...\n", datetimeindex)
print("DateTimeIndex frequency...\n", datetimeindex.freq)
print("\nGetting the day..\n", datetimeindex.day)
आउटपुट
DateTimeIndex... DatetimeIndex(['2021-10-20 02:35:55+11:00', '2021-10-21 02:35:55+11:00', '2021-10-22 02:35:55+11:00', '2021-10-23 02:35:55+11:00', '2021-10-24 02:35:55+11:00', '2021-10-25 02:35:55+11:00'], dtype='datetime64[ns, Australia/Sydney]', freq='D')
DateTimeIndex frequency...
Getting the day.. Int64Index([20, 21, 22, 23, 24, 25], dtype='int64')