找到关于 Python 的10786 篇文章
1K+ 次浏览
要从具有特定时间序列频率的 DateTimeIndex 中提取时区,请使用 DateTimeIndex.tz 属性。首先,导入所需的库 −import pandas as pd 创建一个具有周期 6 和频率为 D(即天)的 DatetimeIndex。时区为澳大利亚/悉尼 −datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=6, tz='Australia/Sydney', freq='D') 显示 DateTimeIndex −print("DateTimeIndex...", datetimeindex) 获取时区 −print("Get the timezone..", datetimeindex.tz) 示例以下为代码 −import pandas as pd # DatetimeIndex with period 6 and frequency as D i.e. day # The timezone is Australia/Sydney datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=6, tz='Australia/Sydney', freq='D') # display DateTimeIndex print("DateTimeIndex...", datetimeindex) # display DateTimeIndex frequency ... 阅读更多
2K+ 次浏览
要从具有特定时间序列频率的 DateTimeIndex 中提取日期的季度,请使用 DateTimeIndex.quarter。首先,导入所需的库 −import pandas as pd 创建一个具有周期 6 和频率为 M(即月)的 DatetimeIndex。时区为澳大利亚/悉尼 −datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=6, tz='Australia/Sydney', freq='2M') 显示 DateTimeIndex 频率 −print("DateTimeIndex frequency...", datetimeindex.freq) 获取日期的季度 −print("Get the quarter of the date..", datetimeindex.quarter) 结果基于以下年份季度 −第一季度 = 1月1日至3月31日 第二季度 = 4月1日至6月30日 第三季度 = 7月1日至9月30日 ... 阅读更多
75 次浏览
假设我们有一个名为 piles 的数字列表和一个值 k。piles[i] 表示第 i 堆上的石头数量。每小时,我们选择任何一堆并从中移除 r 个石头。如果我们选择的一堆石头少于 r 个,那么清除这堆石头仍然需要一小时。我们必须找到 r 的最小值,这样我们才能在小于或等于 k 小时内移除所有石头。因此,如果输入类似于 piles = [3, 6, 4] k = 5,则输出为 ... 阅读更多
231 次浏览
要从具有特定时间序列频率的 DateTimeIndex 中提取星期几,请使用 DateTimeIndex.dayofweek 属性。首先,导入所需的库 −import pandas as pd 创建一个具有周期 6 和频率为 D(即天)的 DatetimeIndex −datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=6, tz='Australia/Sydney', freq='3D') 显示 DateTimeIndex 频率 −print("DateTimeIndex frequency...", datetimeindex.freq) 获取星期几。假设一周从星期一开始,用 0 表示,星期日用 6 表示 −print("Get the day of week..", datetimeindex.dayofweek) 示例以下为代码 −import pandas as pd # DatetimeIndex with period 6 and frequency as ... 阅读更多
266 次浏览
要从具有特定时间序列频率的 DateTimeIndex 中提取一年中的序数天,请使用 DateTimeIndex.dayofyear 属性。首先,导入所需的库 −import pandas as pd 创建一个具有周期 6 和频率为 D(即天)的 DatetimeIndex −datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=6, tz='Australia/Sydney', freq='D') 显示 DateTimeIndex −print("DateTimeIndex...", datetimeindex) 获取一年中的天数 −print("Get the ordinal day of year..", datetimeindex.dayofyear) 示例以下为代码 −import pandas as pd # DatetimeIndex with period 6 and frequency as D i.e. day # The timezone is Australia/Sydney datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=6, tz='Australia/Sydney', freq='D') # display DateTimeIndex print("DateTimeIndex...", datetimeindex) ... 阅读更多
92 次浏览
假设我们有两个列表 nums1 和 nums2,它们表示传感器指标。每个列表都包含唯一值,因此 a ≠ b。这两个列表中的一个包含准确的传感器指标,但另一个包含故障。在故障列表中,一个值(不是最后一个值)被丢弃,并且一个错误的值被放置到该列表的末尾。我们必须找到实际被丢弃的值。因此,如果输入类似于 nums1 = [5, 10, 15] nums2 = [10, 15, 8],则输出将为 5,因为第一个列表 nums1 包含 ... 阅读更多
200 次浏览
要返回具有时区信息的 python datetime.time 对象的 numpy 数组,请使用 datetimeindex.timetz 属性。首先,导入所需的库 −import pandas as pd 创建一个具有周期 5 和频率为 us(即纳秒)的 DatetimeIndex −datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=5, tz='Australia/Sydney', freq='ns') 显示 DateTimeIndex −print("DateTimeIndex...", datetimeindex) 仅返回具有时区信息的 Timestamp 的时间部分 −print("The numpy array (time part with timezone)..", datetimeindex.timetz) 示例以下为代码 −import pandas as pd # DatetimeIndex with period 5 and frequency as us i.e. nanoseconds # The timezone is Australia/Sydney datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=5, tz='Australia/Sydney', freq='ns') # display DateTimeIndex print("DateTimeIndex...", ... 阅读更多
289 次浏览
要返回 python datetime.time 对象的 numpy 数组,请在 Pandas 中使用 datetimeindex.time 属性。首先,导入所需的库 −import pandas as pd 创建一个具有周期 3 和频率为 us(即纳秒)的 DatetimeIndex。时区为澳大利亚/悉尼 −datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=3, tz='Australia/Sydney', freq='ns') 显示 DateTimeIndex −print("DateTimeIndex...", datetimeindex) 仅返回 Timestamp 的时间部分(无时区信息) −print("The numpy array (time part)..", datetimeindex.time) 示例以下为代码 −import pandas as pd # DatetimeIndex with period 3 and frequency as us i.e. nanoseconds # The timezone is Australia/Sydney datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=3, tz='Australia/Sydney', freq='ns') # display DateTimeIndex ... 阅读更多
515 次浏览
要从具有特定时间序列频率的 DateTimeIndex 中提取纳秒,请使用 DateTimeIndex.nanosecond 属性。首先,导入所需的库 −import pandas as pd 创建一个周期为 6 且频率为 ns(即纳秒)的 DatetimeIndex −datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=6, tz='Australia/Sydney', freq='ns') 显示 DateTimeIndex −print("DateTimeIndex...", datetimeindex) 获取纳秒 −print("Getting the nanoseconds..", datetimeindex.nanosecond) 示例以下为代码 −import pandas as pd # 周期为 6 且频率为 ns(即纳秒)的 DatetimeIndex # 时区为澳大利亚/悉尼 datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=6, tz='Australia/Sydney', freq='ns') # 显示 DateTimeIndex print("DateTimeIndex...", datetimeindex) # 显示 DateTimeIndex 频率 print("DateTimeIndex frequency...", datetimeindex.freq) ... 阅读更多
浏览量:178
假设我们有一个值 h 和一个称为 blacklist 的数字列表。我们当前的高度为 h,正在玩一个游戏,将一个小球移动到高度 0。现在,在偶数轮(从 0 开始),我们可以将球向下移动 1、2 或 4 个台阶。在奇数轮中,我们可以将球向下移动 1、3 或 4 个台阶。某些级别列入了黑名单。因此,如果球到达那里,它将立即死亡。我们必须找到球移动到高度 0 的路径数。如果答案是 ... 阅读更多
数据结构
网络
关系数据库管理系统 (RDBMS)
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP