
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 26504 Articles for Server Side Programming

393 Views
To return a new Index of the values set with the mask, use the index.putmask() method in Pandas. At first, import the required libraries −import pandas as pdCreating Pandas index −index = pd.Index([5, 65, 10, 17, 75, 40]) Display the Pandas index −print("Pandas Index...", index)Mask and place index values less than 3 with a value 111 −print("Mask...", index.putmask(index < 30, 111)) ExampleFollowing is the code −import pandas as pd # Creating Pandas index index = pd.Index([5, 65, 10, 17, 75, 40]) # Display the Pandas index print("Pandas Index...", index) # Return the number of elements in the ... Read More

81 Views
To return a new Timedelta ceiled to this resolution, use the timedelta.ceil() method. With that, set the resolution using the freq parameter.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('6 days 1 min 30 s') Display the Timedeltaprint("Timedelta...", timedelta)Return the ceiled Timestamp ceiled to days frequencyres = timedelta.ceil(freq='D') ExampleFollowing 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('6 days 1 min 30 s') # ... Read More

131 Views
To return a new Index of the values selected by the indices, use the index.take() method in Pandas. At first, import the required libraries -import pandas as pdCreating Pandas index −index = pd.Index(['Electronics', 'Accessories', 'Decor', 'Books', 'Toys'], name ='Products') Display the Pandas index −print("Pandas Index...", index)Getting a new index of the values selected by indices −print("A new Index of the values selected by the indices...", index.take([1, 2]))ExampleFollowing is the code −import pandas as pd # Creating Pandas index index = pd.Index(['Electronics', 'Accessories', 'Decor', 'Books', 'Toys'], name ='Products') # Display the Pandas index print("Pandas Index...", index) # Return ... Read More

233 Views
To return the seconds from Timedelta object, use the timedelta.seconds property. At first, import the required libraries −import pandas as pdTimeDeltas is Python’s standard datetime library uses a different representation timedelta’s. Set string input for seconds using unit 's'. Create a Timedelta objecttimedelta = pd.Timedelta('1 min 30 s') Display the Timedeltaprint("Timedelta...", timedelta)Return the seconds valuetimedelta.seconds ExampleFollowing is the code import pandas as pd # TimeDeltas is Python’s standard datetime library uses a different representation timedelta’s # set string input for seconds using unit 's' # create a Timedelta object timedelta = pd.Timedelta('1 min 30 s') # display the ... Read More

275 Views
To return the seconds from Timedelta object, use the timedelta.seconds property. At first, import the required libraries −import pandas as pdTimeDeltas is Python’s standard datetime library uses a different representation timedelta’s. Set integer input for seconds using unit 's'. Create a Timedelta objecttimedelta = pd.Timedelta(50, unit ='s') Display the Timedeltaprint("Timedelta...", timedelta)Return the seconds valuetimedelta.seconds ExampleFollowing is the code import pandas as pd # TimeDeltas is Python’s standard datetime library uses a different representation timedelta’s # set integer input for seconds using unit 's' # create a Timedelta object timedelta = pd.Timedelta(50, unit ='s') # display the Timedelta print("Timedelta...", ... Read More

231 Views
To return the seconds from Timedelta object, use the timedelta.seconds 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('10 s 15 ms 33 ns') Display the Timedeltaprint("Timedelta...", timedelta)Return the seconds valuetimedelta.seconds ExampleFollowing 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('10 s 15 ms 33 ns') # display the Timedelta print("Timedelta...", timedelta) # return the seconds value res = timedelta.seconds ... Read More

257 Views
To replace index values where the condition is False, use the index.isin() method in Pandas. At first, import the required libraries −import pandas as pdCreating Pandas index −index = pd.Index(['Electronics', 'Accessories', 'Decor', 'Books', 'Toys'], name ='Products') Display the Pandas index −print("Pandas Index...", index)Replace values where condition is False. Here, except the 'Decor', every other element gets replaced −print("Replace index vales where condition is False...", index.where(index.isin(['Decor']), 'Miscellaneous'))ExampleFollowing is the code −import pandas as pd # Creating Pandas index index = pd.Index(['Electronics', 'Accessories', 'Decor', 'Books', 'Toys'], name ='Products') # Display the Pandas index print("Pandas Index...", index) # Return the ... Read More

206 Views
To return the nanoseconds 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. Set string input for microseconds using unit 'us'. Create a Timedelta objecttimedelta = pd.Timedelta('12 min 40 us') Display the Timedeltaprint("Timedelta...", timedelta)Return the microseconds valuetimedelta.microseconds ExampleFollowing is the code import pandas as pd # TimeDeltas is Python’s standard datetime library uses a different representation timedelta’s # set string input for microseconds using unit 'us' # create a Timedelta object timedelta = pd.Timedelta('12 min 40 us') # Display the ... Read More

173 Views
To repeat each element of a Pandas Series in a dissimilar way, use the index.repeat() method. At first, import the required libraries -import pandas as pdCreating Pandas index −index = pd.Index(['Car', 'Bike', 'Airplane', 'Ship'], name ='Transport') Display the Pandas index −print("Pandas Index...", index)Repeat each element of the index in a dissimilar way −print("Result after repeating each index element in a different way...", index.repeat([2, 3, 5, 7]))ExampleFollowing is the code −import pandas as pd # Creating Pandas index index = pd.Index(['Car', 'Bike', 'Airplane', 'Ship'], name ='Transport') # Display the Pandas index print("Pandas Index...", index) # Return the number ... Read More

111 Views
To return the nanoseconds 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. Set integer input for microseconds using unit 'us'. Create a Timedelta objecttimedelta = pd.Timedelta(55, unit ='us') Display the Timedeltaprint("Timedelta...", timedelta)Return the microseconds valuetimedelta.microseconds ExampleFollowing is the code import pandas as pd # TimeDeltas is Python’s standard datetime library uses a different representation timedelta’s # set integer input for microseconds using unit 'us' # create a Timedelta object timedelta = pd.Timedelta(55, unit ='us') # display the Timedelta print("Timedelta...", ... Read More