टाइमडेल्टा ऑब्जेक्ट से अवधि के कुल सेकंड प्राप्त करने के लिए, timedelta.total_seconds() मेथड का उपयोग करें।
सबसे पहले, आवश्यक लाइब्रेरी इंपोर्ट करें:
import pandas as pd
TimeDeltas पायथन के स्टैंडर्ड डेटाइम लाइब्रेरी का उपयोग करता है timedelta's के लिए अलग प्रतिनिधित्व, एक टाइमडेल्टा ऑब्जेक्ट बनाएं:
timedelta = pd.Timedelta('2 days 11 hours 22 min 25 s 50 ms 45 ns')
टाइमडेल्टा प्रदर्शित करें:
print("Timedelta...\n", timedelta)
कुल सेकंड प्राप्त करें:
timedelta.total_seconds()
उदाहरण
import pandas as pd
# TimeDeltas is Python's standard datetime library uses a different representation timedelta's
# create a Timedelta object
timedelta = pd.Timedelta('2 days 11 hours 22 min 25 s 50 ms 45 ns')
# display the Timedelta
print("Timedelta...\n", timedelta)
# get the total seconds
res = timedelta.total_seconds()
# Return the result i.e. the total seconds in the duration
print("\nTotal seconds...\n", res)
आउटपुट
Timedelta... 2 days 11:22:25.050000045 Total seconds... 213745.05