
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10476 Articles for Python

192 Views
To return the microseconds from Timedelta object, use the timedelta.microseconds property. At first, import the required libraries −import pandas as pdTimeDeltas is Python’s standard datetime library uses a different representation timedelta’s. Create a Timedelta objecttimedelta = pd.Timedelta('7 days 20 min 15 s 35 ms') Return the microseconds valuetimedelta.microsecondsExampleFollowing is the code import pandas as pd # TimeDeltas is Python’s standard datetime library uses a different representation timedelta’s # create a Timedelta object timedelta = pd.Timedelta('7 days 20 min 15 s 35 ms') # display the Timedelta print("Timedelta...", timedelta) # return the microseconds value res = timedelta.microseconds ... Read More

437 Views
To return the maximum value of the Pandas Index, use the index.max() method. At first, import the required libraries -import pandas as pdCreating Pandas indexindex = pd.Index([10, 20, 70, 40, 90, 50, 25, 30]) Display the Pandas index −print("Pandas Index...", index)Get the maximum value −print("Maximum value..", index.max()) ExampleFollowing is the code −import pandas as pd # Creating Pandas index index = pd.Index([10, 20, 70, 40, 90, 50, 25, 30]) # Display the Pandas index print("Pandas Index...", index) # Return the number of elements in the Index print("Number of elements in the index...", index.size) # Return the ... Read More

530 Views
To return the maximum value of the Timedelta object, timedelta.min property. At first, import the required libraries −import pandas as pdTimeDeltas is Python’s standard datetime library uses a different representation timedelta’s. Create a Timedelta objecttimedelta = pd.Timedelta('2 days 1 min 15 s 20 ns') Return the minimum valuetimedelta.minExampleFollowing is the code 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 1 min 15 s 20 ns') # display the Timedelta print("Timedelta...", timedelta) # return the minimum value res = timedelta.min ... Read More

402 Views
To return the minimum value of the Pandas Index, use the index.min() method. At first, import the required libraries -import pandas as pdCreating Pandas index −index = pd.Index([10.5, 20.4, 40.5, 25.6, 5.7, 6.8, 30.8, 50.2]) Display the Pandas index −print("Pandas Index...", index)Get the minimum value −print("Minimum value..", index.min()) ExampleFollowing is the code −import pandas as pd # Creating Pandas index index = pd.Index([10.5, 20.4, 40.5, 25.6, 5.7, 6.8, 30.8, 50.2]) # Display the Pandas index print("Pandas Index...", index) # Return the number of elements in the Index print("Number of elements in the index...", index.size) # Return ... Read More

724 Views
To return the maximum value of the Timedelta object, timedelta.max property. At first, import the required libraries −import pandas as pdCreate a Timedelta objecttimedelta = pd.Timedelta('5 days 1 min 45 s 40 ns') Return the maximum valuetimedelta.maxExampleFollowing is the code import pandas as pd # TimeDeltas is Python’s standard datetime library uses a different representation timedelta’s # create a Timedelta object timedelta = pd.Timedelta('5 days 1 min 45 s 40 ns') # display the Timedelta print("Timedelta...", timedelta) # return the maximum value res = timedelta.max # display the maximum value print("Timedelta (max value)...", res)OutputThis will produce ... Read More

687 Views
To check if the Pandas Index is of the object dtype, use the index.is_object() method. At first, import the required libraries -import pandas as pdCreating Pandas index −index = pd.Index(["Electronics", 6, 10.5, "Accessories", 25.6, 30]) Display the Pandas index −print("Pandas Index...", index)Check whether index values has object dtype −print("Is the Index of object dtype?", index.is_object()) ExampleFollowing is the code −import pandas as pd # Creating Pandas index index = pd.Index(["Electronics", 6, 10.5, "Accessories", 25.6, 30]) # Display the Pandas index print("Pandas Index...", index) # Return the number of elements in the Index print("Number of elements in the ... Read More

910 Views
Use the timedelta.delta property in Pandas to get the timedelta in nanoseconds for internal compatibility.At first, import the required libraries −import pandas as pdTimeDeltas is Python’s standard datetime library uses a different representation timedelta’s. Create a Timedelta objecttimedelta = pd.Timedelta('5 days 1 min 45 s 40 ns') Return the timedelta in nanosecondstimedelta.deltaExampleFollowing is the code import pandas as pd # TimeDeltas is Python’s standard datetime library uses a different representation timedelta’s # create a Timedelta object timedelta = pd.Timedelta('5 days 1 min 45 s 40 ns') # display the Timedelta print("Timedelta...", timedelta) # return the timedelta in ... Read More

611 Views
To check if the Pandas Index only consists of numeric data, use the index.is_numeric() method. At first, import the required libraries -import pandas as pd import numpy as npCreating Pandas index with integer, float and NaNsindex = pd.Index([5, 10.2, 25, 50, 75.2, 100, np.nan]) Display the Pandas index −print("Pandas Index...", index)Check whether index values has only numeric data. Numeric data includes integer, floats and NaNs −index.is_numeric() ExampleFollowing is the code −import pandas as pd import numpy as np # Creating Pandas index with integer, float and NaNs index = pd.Index([5, 10.2, 25, 50, 75.2, 100, np.nan]) # Display ... Read More

9K+ Views
To get the number of days from TimeDelta, use the timedelta.days property in Pandas. At first, import the required libraries −import pandas as pdTimeDeltas is Python’s standard datetime library uses a different representation timedelta’s. Create a Timedelta objecttimedelta = pd.Timedelta('5 days 1 min 45 s') Return the number of daystimedelta.daysExampleFollowing is the code import pandas as pd # TimeDeltas is Python’s standard datetime library uses a different representation timedelta’s # create a Timedelta object timedelta = pd.Timedelta('5 days 1 min 45 s') # display the Timedelta print("Timedelta...", timedelta) # return the number of days res = timedelta.days ... Read More

162 Views
To return a components namedtuple-like, use the timedelta.components. At first, import the required libraries −import pandas as pdTimeDeltas is Python’s standard datetime library uses a different representation timedelta’s. Create a Timedelta objecttimedelta = pd.Timedelta('1 days 10 min 20 s') Return a components namedtuple-liketimedelta.componentsExampleFollowing is the code import pandas as pd # TimeDeltas is Python’s standard datetime library uses a different representation timedelta’s # create a Timedelta object timedelta = pd.Timedelta('1 days 10 min 20 s') # display the Timedelta print("Timedelta...", timedelta) # return a components namedtuple-like res = timedelta.components # display the component print("Component...", res)OutputThis will ... Read More