
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

98 Views
To return the Period object as a timestamp with monthly frequency, use the period.to_timestamp() method and set the freq parameter as ‘T’.At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating a Period objectperiod = pd.Period(freq="S", year = 2021, month = 11, day = 26, hour = 11, minute = 45, second = 55) Display the Period object print("Period...", period)Return the Timestamp representation of the Period object. We have set the frequency using the "freq" parameter. The frequency is set as 'T' i.e. minutelyprint("Period to Timestamp with minutely frequency...", period.to_timestamp(freq='T')) ExampleFollowing is the ... Read More

280 Views
To return the Period object as a timestamp with monthly frequency, use the period.to_timestamp() method and set the freq parameter as ‘M’.At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating a Period objectperiod = pd.Period(freq="S", year = 2021, month = 9, day = 18, hour = 17, minute = 20, second = 45) Display the Period objectprint("Period...", period)Return the Timestamp representation of the Period object. We have set the frequency using the "freq" parameter. The frequency is set as 'M' i.e. monthlyprint("Period to Timestamp with monthly (month-end) frequency...", period.to_timestamp(freq='M'))ExampleFollowing is the code ... Read More

128 Views
To return the Timestamp representation of the Period object, use the period.to_timestamp() method.At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating a Period objectperiod = pd.Period(freq="S", year = 2021, month = 9, day = 18, hour = 17, minute = 20, second = 45)Display the Period objectprint("Period...", period) Return the Timestamp representation of the Period object. We have set the frequency using the "freq" parameterprint("Period to Timestamp...", period.to_timestamp(freq='T'))ExampleFollowing is the code import pandas as pd # The pandas.Period represents a period of time # Creating a Period object period = pd.Period(freq="S", ... Read More

948 Views
To format the Period object, use the period.strftime() method and to display the time with 24-Hour format, set the parameter as %H.At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating a Period objectperiod = pd.Period(freq="S", year = 2021, month = 9, day = 18, hour = 17, minute = 20, second = 45)Display the Period objectprint("Period...", period) Display the result. Here, Time is displayed with 24-Hour format i.e. [00, 23]print("String representation (24-Hour format)...", period.strftime('%H'))ExampleFollowing is the code import pandas as pd # The pandas.Period represents a period of time # Creating ... Read More

256 Views
To format the Period object, use the period.strftime() method and to display the year without century, set the parameter as %y.At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating a Period objectperiod = pd.Period(freq="S", year = 2021, month = 9, day = 18, hour = 8, minute = 20, second = 45) Display the Period objectprint("Period...", period)Display the result. Here, year is displayed without centuryprint("String representation (year without century)...", period.strftime('%y')) ExampleFollowing is the code import pandas as pd # The pandas.Period represents a period of time # Creating a Period object ... Read More

2K+ Views
To format the Period object, use the period.strftime() method and to display Quarter, set the parameter as Q%q.At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating a Period objectperiod = pd.Period(freq="S", year = 2021, month = 9, day = 18, hour = 8, minute = 20, second = 45) Display the Period objectprint("Period...", period)Display the result. Here, Period object is formatted and Quarter is displayedprint("String representation (display quarter)...", period.strftime('Q%q')) ExampleFollowing is the code import pandas as pd # The pandas.Period represents a period of time # Creating a Period object period ... Read More

1K+ Views
To format and return the string representation of the Period object, use the period.strftime() method. With that, set the format specifiers as an argument like strftime('%d-%b-%Y').At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating a Period objectperiod = pd.Period(freq="S", year = 2021, month = 9, day = 18, hour = 8, minute = 20, second = 45) Display the Period objectprint("Period...", period)Display the formatted string representationprint("String representation (format)...", period.strftime('%d-%b-%Y')) ExampleFollowing is the code import pandas as pd # The pandas.Period represents a period of time # Creating a Period object period ... Read More

206 Views
To change the frequency of the given Period object from Seconds to Minutely frequency, use the period.asfreq() method and set the parameter ‘T’.At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating a Period object. We have set the frequency as seconds i.e. 'S' using the 'freq' parameter period = pd.Period(freq="S", year = 2021, month = 9, day = 11, hour = 8, minute = 20, second = 45)Display the Period object with Seconds frequencyprint("Period...", period) Convert Period from Seconds to Minutely frequency. We have set the "T" to convert seconds to minutely ... Read More

735 Views
To change the frequency of the given Period object from Seconds to Hourly frequency, use the period.asfreq() method and set the parameter ‘H’.At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating a Period object. We have set the frequency as seconds ie. 'S' using the 'freq' parameterperiod = pd.Period(freq="S", year = 2021, month = 4, day = 16, hour = 2, minute = 35, second = 15) Display the Period object with Seconds frequencyprint("Period...", period)Convert Period from Seconds to Hourly frequency. We have set the "H" to convert seconds to hourly frequency ... Read More

547 Views
To change the frequency of the given Period object from Seconds to Daily frequency, use the period.asfreq() method and set the parameter ‘D’.At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating a Period object. We have set the frequency as seconds ie. 'S' using the 'freq' parameterperiod = pd.Period(freq="S", year = 2021, month = 4, day = 16, hour = 2, minute = 35, second = 15)Display the Period object with Seconds frequencyprint("Period...", period) Convert Period from Seconds to Daily frequency. We have set the "D" to convert seconds to daily frequency ... Read More