Timedelta ऑब्जेक्ट से नैनोसेकंड वापस करने के लिए, timedelta.nanoseconds का उपयोग करें संपत्ति। सबसे पहले, आवश्यक पुस्तकालयों को आयात करें -
import pandas as pd
TimeDeltas पायथन का मानक डेटाटाइम लाइब्रेरी है जो एक अलग प्रतिनिधित्व टाइमडेल्टा का उपयोग करता है। इकाई 'एनएस' का उपयोग करके नैनोसेकंड के लिए स्ट्रिंग इनपुट सेट करें। Timedelta ऑब्जेक्ट बनाएं
timedelta = pd.Timedelta('10 min 40 ns') टाइमडेल्टा प्रदर्शित करें
print("Timedelta...\n", timedelta)
नैनोसेकंड मान लौटाएं
timedelta.nanoseconds
उदाहरण
निम्नलिखित कोड है
import pandas as pd
# TimeDeltas is Python’s standard datetime library uses a different representation timedelta’s
# set string input for nanoseconds using unit 'ns'
# create a Timedelta object
timedelta = pd.Timedelta('10 min 40 ns')
# display the Timedelta
print("Timedelta...\n", timedelta)
# return the nanoseconds value
res = timedelta.nanoseconds
# display the nanoseconds
print("\nTimedelta (nanoseconds value)...\n", res) आउटपुट
यह निम्नलिखित कोड उत्पन्न करेगा
Timedelta... 0 days 00:10:00.000000040 Timedelta (nanoseconds value)... 40