Skip to Content
利用 Python 进行数据分析:原书第 3 版
book

利用 Python 进行数据分析:原书第 3 版

by Wes McKinney
November 2023
Intermediate to advanced
512 pages
11h 53m
Chinese
China Machine Press
Content preview from 利用 Python 进行数据分析:原书第 3 版
336
|
11
11.2
时间序列基础知识
pandas
最基本的时间序列类型就是以时间戳为索引的
Series
,时间戳通常以
Python
字符
串或 datatime 对象表示:
在底层,这些 datetime 对象实际上是放在 DatetimeIndex 中的:
与其他
Series
一样,不同索引的时间序列之间的算术运算会自动按日期对齐:
ts[::2] 是每隔两个值取一个值。
pandas
NumPy
datetime64 数据类型,以纳秒精度存储时间戳:
DatetimeIndex 中的各个标量值是
pandas
Timestamp 对象:
时间序列
|
337
只要有需要,pandas.TimeStamp 可以随时自动转换为 datetime 对象。但是,pandas.
TimeStamp 不能进行逆运算,因为它存储的是纳秒精度的数据,而 datetime 只能存储到
微秒级别。此外,pandas.TimeStamp 还可以存储频率信息(如果有的话),并可以执行
时区转换以及其他操作,稍后在
11.4
节将对此进行详细讲解。
11.2.1
索引、选取、子集构造
当根据标签进行索引和选取数据时,时间序列和其他的
Series
很像:
为了方便,也可以传入一个可以解释为日期的字符串:
对于较长的时间序列,只需传入“ ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Effective Python 第3版 ―Pythonプログラムを改良する125項目

Effective Python 第3版 ―Pythonプログラムを改良する125項目

Brett Slatkin, 鈴木 駿

Publisher Resources

ISBN: 9787111726722