{"id":30618,"date":"2022-09-03T12:00:48","date_gmt":"2022-09-03T06:30:48","guid":{"rendered":"https:\/\/btechgeeks.com\/?p=30618"},"modified":"2022-09-03T12:34:09","modified_gmt":"2022-09-03T07:04:09","slug":"python-pandas-timestamp-floor-function","status":"publish","type":"post","link":"https:\/\/btechgeeks.com\/python-pandas-timestamp-floor-function\/","title":{"rendered":"Pandas floor – Python Pandas Timestamp.floor() Function"},"content":{"rendered":"
What is Timestamp?<\/strong><\/p>\n Pandas floor: <\/strong>A timestamp is a sequence of characters or encoded information that identifies when a particular event occurred, typically providing the date and time of day, and can be accurate to a fraction of a second.<\/p>\n The timestamp method is used for a variety of synchronization purposes, including assigning a sequence order to a multievent transaction so that the transaction can be canceled if a fault occurs. A timestamp can also be used to record time in reference to a specific starting point in time.<\/p>\n Uses of Timestamp:<\/strong><\/p>\n Timestamps are used to maintain track of information stored online or on a computer. A timestamp indicates when data was generated, shared, modified, or removed.<\/p>\n Here are some examples of how timestamps can be used:<\/p>\n Pandas Timestamp.floor() Function:<\/strong><\/p>\n The Timestamp.floor() function of the Pandas module gives a new Timestamp floored to this resolution. As an input, the function accepts the specified time series frequency.<\/p>\n Syntax:<\/strong><\/p>\n Parameters:\u00a0<\/strong><\/p>\n freq:<\/strong> It is a frequency string that represents the flooring resolution.<\/p>\n Return Value:<\/strong><\/p>\n A new Timestamp is returned by the Timestamp.floor() function of the Pandas module<\/p>\n Example1<\/strong><\/p>\n Here, The Timestamp.floor() function has floored the time series frequency of the given Timestamp object to the input frequency.<\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n <\/p>\n","protected":false},"excerpt":{"rendered":" What is Timestamp? Pandas floor: A timestamp is a sequence of characters or encoded information that identifies when a particular event occurred, typically providing the date and time of day, and can be accurate to a fraction of a second. The timestamp method is used for a variety of synchronization purposes, including assigning a sequence … Read more<\/a><\/p>\n","protected":false},"author":7,"featured_media":31224,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[5],"tags":[],"yoast_head":"\n\n
Timestamp.floor(freq)<\/pre>\n
Pandas Timestamp.floor() Function in Python<\/h2>\n
\n
# Import pandas module using the import keyword.\r\nimport pandas as pd\r\n \r\n# Pass some random year, month, day, hour, minute, tz ='Asia\/Kolkata'\r\n# (Timezone) as the arguments to the Timestamp() function of the\r\n# pandas module to get the Timestamp object\r\ntime_stamp_obj = pd.Timestamp(year = 2017, month = 5, day = 16, hour = 12, \r\n minute = 28, tz = 'Asia\/Kolkata' ) \r\n# Print the above obtained Timestamp object\r\nprint(\"The above obtained Timestamp object:\", time_stamp_obj)\r\nprint()\r\n# Pass freq = 'D' as an argument the floor() function and apply it on the above \r\n# Timestamp object to get floored values of the above Timestamp object to \r\n# daily frequency\r\nprint(\"The floored values of the above Timestamp object to daily frequency:\")\r\ntime_stamp_obj.floor(freq ='D')\r\n<\/pre>\n
The above obtained Timestamp object: 2017-05-16 12:28:00+05:30\r\n\r\nThe floored values of the above Timestamp object to daily frequency:\r\nTimestamp('2017-05-16 00:00:00+0530', tz='Asia\/Kolkata')<\/pre>\n
\n
# Import pandas module using the import keyword.\r\nimport pandas as pd\r\n \r\n# Pass some random year, month, day, hour, minute, tz ='US\/Central'\r\n# (Timezone) as the arguments to the Timestamp() function of the\r\n# pandas module to get the Timestamp object\r\ntime_stamp_obj = pd.Timestamp(year = 2020, month = 8, day = 5, hour = 4, \r\n minute = 30, tz = 'US\/Central' ) \r\n# Print the above obtained Timestamp object\r\nprint(\"The above obtained Timestamp object:\", time_stamp_obj)\r\nprint()\r\n# Pass freq = 'T' as an argument to the floor() function and apply it on the above \r\n# Timestamp object to get floored values of the above Timestamp object to \r\n# minutely frequency\r\nprint(\"The floored values of the above Timestamp object to minutely frequency:\")\r\ntime_stamp_obj.floor(freq ='T')\r\n<\/pre>\n
The above obtained Timestamp object: 2020-08-05 04:30:00-05:00\r\n\r\nThe floored values of the above Timestamp object to minutely frequency:\r\nTimestamp('2020-08-05 04:30:00-0500', tz='US\/Central')<\/pre>\n