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
Server Side Programming Articles - Page 843 of 2650
216 Views
To find the end time for the given Period object, use the period.end_time property.At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating two Period objects −period1 = pd.Period("2020-09-23 03:55:20") period2 = pd.Period(freq="T", year = 2021, month = 2, day = 14, hour = 2, minute = 35)Display the Period objects −print("Period1...", period1) print("Period2...", period2)Get the end time from two Period objects −res1 = period1.end_time res2 = period2.end_timeExampleFollowing is the code −import pandas as pd # The pandas.Period represents a period of time # creating two Period objects period1 = pd.Period("2020-09-23 03:55:20") ... Read More
468 Views
To get the frequency for the given Period object, use the period.freq property.At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating two Period objects −period1 = pd.Period("2020-09-23 03:55:20") period2 = pd.Period(freq="T", year = 2021, month = 2, day = 14, hour = 2, minute = 35)Display the Period objects −print("Period1...", period1) print("Period2...", period2)Get the frequency from two Period objects −res1 = period1.freq res2 = period2.freqExampleFollowing is the code −import pandas as pd # The pandas.Period represents a period of time # creating two Period objects period1 = pd.Period("2020-09-23 03:55:20") period2 = pd.Period(freq="T", ... Read More
150 Views
To form the Union of two Index objects, use the index1.union(index2) method in Pandas. At first, import the required libraries −import pandas as pdCreating two Pandas index −index1 = pd.Index([10, 20, 30, 40, 50]) index2 = pd.Index([80, 65, 60, 70, 55])Display the Pandas index1 and index2 −print("Pandas Index1...", index1) print("Pandas Index2...", index2)Perform union −res = index1.union(index2) ExampleFollowing is the code −import pandas as pd # Creating two Pandas index index1 = pd.Index([10, 20, 30, 40, 50]) index2 = pd.Index([80, 65, 60, 70, 55]) # Display the Pandas index1 and index2 print("Pandas Index1...", index1) print("Pandas Index2...", index2) # ... Read More
717 Views
To get the total number of days of the month that a Period falls on, use the period.daysinmonth property.At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating two Period objects −period1 = pd.Period("2020-09-23") period2 = pd.Period(freq="D", year = 2021, month = 2, day = 14, hour = 2, minute = 35)Display the Period objects −print("Period1...", period1) print("Period2...", period2)Get the days in the month from two Period objects −res1 = period1.daysinmonth res2 = period2.daysinmonthExampleFollowing is the code −import pandas as pd # The pandas.Period represents a period of time # creating two ... Read More
669 Views
To form the intersection of two Index objects, use the index1.intersection(index2) method in Pandas. To sort the result, use the sort parameter.At first, import the required libraries −import pandas as pdCreating Pandas index1 and index2 −index1 = pd.Index([4, 3, 2, 1]) index2 = pd.Index([8, 2, 6, 4])Display the Pandas index1 and index2print("Pandas Index1...", index1) print("Pandas Index2...", index2)Perform intersection. The results are sorted using the "sort" parameterres = index1.intersection(index2, sort=None) ExampleFollowing is the code −import pandas as pd # Creating Pandas index1 and index2 index1 = pd.Index([4, 3, 2, 1]) index2 = pd.Index([8, 2, 6, 4]) # Display the ... Read More
205 Views
To get day of the year from Period object, use the period.dayofyear property.At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating two Period objects −period1 = pd.Period("2020-09-23") period2 = pd.Period(freq="D", year = 2021, month = 7, day = 16, hour = 2, minute = 35)Display the Period objects −print("Period1...", period1) print("Period2...", period2)Get the day of the year from two Period objects −res1 = period1.dayofyear res2 = period2.dayofyearExampleFollowing is the code −import pandas as pd # The pandas.Period represents a period of time # creating two Period objects period1 = pd.Period("2020-09-23") period2 = ... Read More
186 Views
To get day of the week that a Period falls on, use the period.dayofweek propertyAt first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating two Period objects −period1 = pd.Period("2021-09-18") period2 = pd.Period(freq ='D', year = 2021, month = 9, day = 22, hour = 4, minute = 55)Display the Period objects −print("Period1...", period1) print("Period2...", period2)Get the day of week from two Period objects −res1 = period1.dayofweek res2 = period2.dayofweekExampleFollowing is the code −import pandas as pd # The pandas.Period represents a period of time # creating two Period objects period1 = ... Read More
245 Views
To form the intersection of two Index objects, use the index1.intersection(index2) method in Pandas. At first, import the required libraries −import pandas as pdCreating two Pandas index −index1 = pd.Index([10, 20, 30, 40, 50]) index2 = pd.Index([80, 65, 60, 70, 55])Display the Pandas index1 and index2 −print("Pandas Index1...", index1) print("Pandas Index2...", index2)Perform intersection −res = index1.intersection(index2) ExampleFollowing is the code −import pandas as pd # Creating two Pandas index index1 = pd.Index([10, 20, 30, 40, 50]) index2 = pd.Index([80, 65, 60, 70, 55]) # Display the Pandas index1 and index2 print("Pandas Index1...", index1) print("Pandas Index2...", index2) # ... Read More
213 Views
To get day of the month that a Period falls on, use the period.day property.At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating two Period objects−period1 = pd.Period("2021-09-18") period2 = pd.Period(freq ='D', year = 2021, month = 9, day = 22, hour = 4, minute = 55)Get the day of the month from two Period objects −res1 = period1.day res2 = period2.dayExampleFollowing is the code −import pandas as pd # The pandas.Period represents a period of time # creating two Period objects period1 = pd.Period("2021-09-18") period2 = pd.Period(freq ='D', year = 2021, ... Read More
473 Views
To append a collection of Index options together, use the append() method in Pandas. At first, import the required libraries −import pandas as pdCreating Pandas index −index1 = pd.Index([10, 20, 30, 40, 50]) Display the Pandas index −print("Pandas Index...", index1)Create a new index to be appended −index2 = pd.Index([60, 70, 80]) Append the new index −print("After appending...", index1.append(index2))ExampleFollowing is the code −import pandas as pd # Creating Pandas index index1 = pd.Index([10, 20, 30, 40, 50]) # Display the Pandas index print("Pandas Index...", index1) # Return the number of elements in the Index print("Number of elements in ... Read More