
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

344 Views
To perform floor operation on the DateTimeIndex with milliseconds frequency, use the DateTimeIndex.floor() method. For milliseconds frequency, use the freq parameter with value ‘ms’.At first, import the required libraries −import pandas as pdDatetimeIndex with period 7 and frequency as S i.e. seconds −datetimeindex = pd.date_range('2021-10-18 07:20:32.261811624', periods=5, tz='Australia/Adelaide', freq='40S')Display DateTimeIndex −print("DateTimeIndex...", datetimeindex) Floor operation on DateTimeIndex date with milliseconds frequency. For milliseconds frequency, we have used 'ms' −print("Performing floor operation with milliseconds frequency...", datetimeindex.floor(freq='ms'))ExampleFollowing is the code −import pandas as pd # DatetimeIndex with period 7 and frequency as S i.e. seconds # timezone is Australia/Adelaide datetimeindex = pd.date_range('2021-10-18 ... Read More

178 Views
To perform floor operation on the DateTimeIndex with seconds frequency, use the DateTimeIndex.floor() method. For seconds frequency, use the freq parameter with value ‘S’At first, import the required libraries −import pandas as pdCreate a DatetimeIndex with period 7 and frequency as S i.e. seconds −datetimeindex = pd.date_range('2021-10-18 07:20:32.261811624', periods=5, tz='Australia/Adelaide', freq='40S')Display DateTimeIndex −print("DateTimeIndex...", datetimeindex) Floor operation on DateTimeIndex date with seconds frequency. For seconds frequency, we have used 'S' −print("Performing floor operation with seconds frequency...", datetimeindex.floor(freq='S'))ExampleFollowing is the code −import pandas as pd # DatetimeIndex with period 7 and frequency as S i.e. seconds # timezone is Australia/Adelaide datetimeindex ... Read More

118 Views
To perform floor operation on the DateTimeIndex with minutely frequency, use the DateTimeIndex.floor() method. For minutely frequency, use the freq parameter with value ‘T’.At first, import the required libraries −import pandas as pdCreate a DatetimeIndex with period 7 and frequency as s i.e. seconds −datetimeindex = pd.date_range('2021-10-18 07:20:32.261811624', periods=5, tz='Australia/Adelaide', freq='40S')Display DateTimeIndex −print("DateTimeIndex...", datetimeindex) Floor operation on DateTimeIndex date with minute frequency. For minute frequency, we have used 'T' −print("Performing floor operation with minute frequency...", datetimeindex.floor(freq='T'))ExampleFollowing is the code −import pandas as pd # DatetimeIndex with period 7 and frequency as s i.e. seconds # timezone is Australia/Adelaide datetimeindex ... Read More

168 Views
To perform floor operation on the DateTimeIndex with hourly frequency, use the DateTimeIndex.floor() method. For hourly frequency, use the freq parameter with value ‘H’.At first, import the required libraries −import pandas as pdCreate a DatetimeIndex with period 5 and frequency as min i.e. minutes −datetimeindex = pd.date_range('2021-09-29 07:20:32.261811624', periods=5, tz='Australia/Adelaide', freq='20min')Display DateTimeInde −print("DateTimeIndex...", datetimeindex)Floor operation on DateTimeIndex date with hourly frequency, For hourly frequency, we have used 'H' −print("Performing floor operation with hourly frequency...", datetimeindex.floor(freq='H'))ExampleFollowing is the code −import pandas as pd # DatetimeIndex with period 5 and frequency as min i.e. minutes # timezone is Australia/Adelaide datetimeindex = ... Read More

189 Views
To round the DateTimeIndex with microseconds frequency, use the DateTimeIndex.round() method. For microseconds frequency, use the freq parameter with value ‘us’.At first, import the required libraries −import pandas as pdCreate a DatetimeIndex with period 5 and frequency as s i.e. seconds −datetimeindex = pd.date_range('2021-09-29 07:20:32.261811624', periods=5, tz='Australia/Adelaide', freq='28s')Round operation on DateTimeIndex date with microseconds frequency. For microseconds frequency, we have used 'us' −print("Performing round operation with microseconds frequency...", datetimeindex.round(freq='us'))ExampleFollowing is the code −import pandas as pd # DatetimeIndex with period 5 and frequency as s i.e. seconds # timezone is Australia/Adelaide datetimeindex = pd.date_range('2021-09-29 07:20:32.261811624', periods=5, tz='Australia/Adelaide', freq='28s') ... Read More

134 Views
To round the DateTimeIndex with frequency as multiples of a single unit, use the DateTimeIndex.round() method. Set the freq parameter for frequency.At first, import the required libraries −import pandas as pdDatetimeIndex with period 5 and frequency as H i.e. hours −datetimeindex = pd.date_range('2021-09-29 07:20:32.261811624', periods=5, tz='Australia/Adelaide', freq='H')Display DateTimeIndex −print("DateTimeIndex...", datetimeindex) Round a DateTimeIndex with 10 minutes frequency i.e. multiples of a single unit. For minutes frequency, we have used 'T −print("Performing round operation with multiples of a single unit frequency...", datetimeindex.round(freq='10T'))ExampleFollowing is the code −import pandas as pd # DatetimeIndex with period 5 and frequency as H i.e. hours ... Read More

1K+ Views
To round the DateTimeIndex with milliseconds frequency, use the DateTimeIndex.round() method. For milliseconds frequency, use the freq parameter with value ‘ms’.At first, import the required libraries −import pandas as pdCreate a DatetimeIndex with period 5 and frequency as s i.e. seconds −datetimeindex = pd.date_range('2021-09-29 07:20:32.261811624', periods=5, tz='Australia/Adelaide', freq='28s')Round operation on DateTimeIndex date with milliseconds frequency. For milliseconds frequency, we have used 'ms' −print("Performing round operation with milliseconds frequency...", datetimeindex.round(freq='ms'))ExampleFollowing is the code −import pandas as pd # DatetimeIndex with period 5 and frequency as s i.e. seconds # timezone is Australia/Adelaide datetimeindex = pd.date_range('2021-09-29 07:20:32.261811624', periods=5, tz='Australia/Adelaide', freq='28s') ... Read More

995 Views
To round the DateTimeIndex with seconds frequency, use the DateTimeIndex.round() method. For seconds frequency, use the freq parameter with value ‘S’.At first, import the required libraries −import pandas as pdCreate a DatetimeIndex with period 5 and frequency as s i.e. seconds −datetimeindex = pd.date_range('2021-09-29 07:20:32.261811624', periods=5, tz='Australia/Adelaide', freq='28s')Round operation on DateTimeIndex date with seconds frequency. For seconds frequency, we have used 'S' −print("Performing round operation with seconds frequency...", datetimeindex.round(freq='S'))ExampleFollowing is the code −import pandas as pd # DatetimeIndex with period 5 and frequency as s i.e. seconds # timezone is Australia/Adelaide datetimeindex = pd.date_range('2021-09-29 07:20:32.261811624', periods=5, tz='Australia/Adelaide', freq='28s') ... Read More

166 Views
To extract year from the DateTimeIndex with specific time series frequency, use the DateTimeIndex.day property.At first, import the required libraries −import pandas as pdDatetimeIndex with period 6 and frequency as D i.e. day. The timezone is Australia/Sydney −datetimeindex = pd.date_range('2021-10-20 02:35:55', periods=6, tz='Australia/Sydney', freq='D')Display DateTimeIndex −print("DateTimeIndex...", datetimeindex)Get the day −print("Getting the day..", datetimeindex.day) ExampleFollowing is the code −import pandas as pd # DatetimeIndex with period 6 and frequency as D i.e. day # timezone is Australia/Sydney datetimeindex = pd.date_range('2021-10-20 02:35:55', periods=6, tz='Australia/Sydney', freq='D') # display DateTimeIndex print("DateTimeIndex...", datetimeindex) # display DateTimeIndex frequency print("DateTimeIndex frequency...", datetimeindex.freq) # ... Read More

1K+ Views
To extract month number from the DateTimeIndex with specific time series frequency, use the DateTimeIndex.month property.At first, import the required libraries −import pandas as pdDatetimeIndex with period 6 and frequency as M i.e. month. The timezone is Australia/Sydney −datetimeindex = pd.date_range('2021-09-24 02:35:55', periods=6, tz='Australia/Sydney', freq='M')Display DateTimeIndex −print("DateTimeIndex...", datetimeindex)Get the month number i.e. January=1, february=2, ..., December=12 −print("Getting the month number..", datetimeindex.month) ExampleFollowing is the code −import pandas as pd # DatetimeIndex with period 6 and frequency as M i.e. month # timezone is Australia/Sydney datetimeindex = pd.date_range('2021-09-24 02:35:55', periods=6, tz='Australia/Sydney', freq='M') # display DateTimeIndex print("DateTimeIndex...", datetimeindex) # ... Read More