Python是进行数据分析的一种出色语言, 主要是因为以数据为中心的python软件包具有奇妙的生态系统。大熊猫是这些软件包之一, 使导入和分析数据更加容易。
大熊猫Timestamp.now()函数返回本地时区的当前时间。等效于datetime.now([tz])。
语法:Timestamp.now()参数:无返回:时间戳记示例1:采用Timestamp.now()函数返回本地时区的当前时间。
# importing pandas as pd
import pandas as pd# Create the Timestamp object
ts = pd.Timestamp(year = 2011 , month = 11 , day = 21 , hour = 10 , second = 49 , tz = 'US/Central' )# Print the Timestamp object
print (ts)
输出:

文章图片
现在我们将使用Timestamp.now()函数以查找当地时区的当前时间。
# return the current time
ts.now()
输出:

文章图片
正如我们在输出中看到的,
Timestamp.now()
函数已返回当地时区的当前时间。它会自动检测本地时区。
示例2:
采用
Timestamp.now()
函数返回本地时区的当前时间。
# importing pandas as pd
import pandas as pd# Create the Timestamp object
ts = pd.Timestamp(year = 2009 , month = 5 , day = 31 , hour = 4 , second = 49 , tz = 'Europe/Berlin' )# Print the Timestamp object
print (ts)
输出:

文章图片
现在我们将使用Timestamp.now()函数以查找当地时区的当前时间。
# return the current time
ts.now()
输出:

文章图片
正如我们在输出中看到的, Timestamp.now()函数已返回当地时区的当前时间。它会自动检测本地时区。
【Python Pandas时间戳now用法介绍】首先, 你的面试准备可通过以下方式增强你的数据结构概念:Python DS课程。
推荐阅读
- Python Pandas时间戳isoformat介绍
- Python Pandas时间戳替换
- Python Pandas时间戳介绍和用法实例
- Python Pandas.to_datetime()用法介绍
- Python Pandas tseries.offsets.DateOffset用法介绍
- Python Pandas处理文本数据详细指南
- Python Tkinter中的PanedWindow小部件用法
- Python Tkinter中的place()方法用法示例
- Python Kivy中的弹出窗口小部件用法