Python | Панды Timestamp.round
Python - отличный язык для анализа данных, в первую очередь из-за фантастической экосистемы пакетов Python, ориентированных на данные. Pandas - один из таких пакетов, который значительно упрощает импорт и анализ данных.
Pandas Timestamp.round() function is used to round the given Timestamp to the specified resolution.
Syntax :Timestamp.round()
Parameters :
freq : a freq string indicating the rounding resolutionReturn : a new Timestamp rounded to the given resolution of freq
Example #1: Use Timestamp.round() function to round the given Timestamp to Daily time series frequency.
# importing pandas as pdimport pandas as pd # Create the Timestamp objectts = pd.Timestamp(year = 2011, month = 11, day = 21, hour = 10, second = 49, tz = "US/Central") # Print the Timestamp objectprint(ts) |
Выход :

Now we will use the Timestamp.round() function to round the given Timestamp object to Daily frequency.
# round to daily frequencyts.round(freq = "D") |
Выход :

As we can see in the output, the Timestamp.round() function has returned a Timestamp object having the time series frequency rounded to the desired resolution.
Example #2: Use Timestamp.round() function to round the given Timestamp to minutely time series frequency.
Выход :

Now we will use the Timestamp.round() function to round the given Timestamp object to minutely frequency.
# round to minutely frequencyts.round(freq = "T") |
Выход :

As we can see in the output, the Timestamp.round() function has returned a Timestamp object having the time series frequency rounded to the desired resolution.
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.