版本 0.9.0 (2012 年 10 月 7 日)#
这是从 0.8.1 版本开始的一个主要版本,包含多项新特性和增强功能,以及大量错误修复。新特性包括 Series.str
的矢量化 Unicode 编码/解码、DataFrame 的 to_latex
方法、更灵活的布尔值解析,以及支持从 Yahoo! Finance 下载期权数据。
新特性#
为 Series.str 中的矢量化字符串处理方法添加用于 Unicode 处理的
encode
和decode
方法 (GH 1706)添加
DataFrame.to_latex
方法 (GH 1735)添加所有 rolling_* 操作的便捷扩展窗口等效项 (GH 1785)
在 pandas.io.data 中添加 Options 类,用于从 Yahoo! Finance 获取期权数据 (GH 1748, GH 1739)
为
Series.reset_index
添加level
参数
TimeSeries.between_time
现在可以跨午夜选择时间 (GH 1871)Series 构造函数现在可以接受生成器作为输入 (GH 1679)
DataFrame.dropna
现在可以接受多个轴 (元组/列表) 作为输入 (GH 924)在
ExcelFile.parse
中启用skip_footer
参数 (GH 1843)
API 更改#
当
header=None
且未向read_csv
等函数传递列名时,默认列名已更改为更符合 Python 习惯且便于属性访问的格式
In [1]: import io
In [2]: data = """
...: 0,0,1
...: 1,1,0
...: 0,1,0
...: """
...:
In [3]: df = pd.read_csv(io.StringIO(data), header=None)
In [4]: df
Out[4]:
0 1 2
0 0 0 1
1 1 1 0
2 0 1 0
[3 rows x 3 columns]
从另一个 Series 创建 Series 并传递索引时,将导致内部进行重新索引,而不是将该 Series 视为 ndarray。以前“偶然”有效(从未意图如此)的不当用法,例如
Series(df[col1], index=df[col2])
,在某些情况下将导致所有值为 NA 的 Series。为了更清楚地说明
In [5]: s1 = pd.Series([1, 2, 3])
In [6]: s1
Out[6]:
0 1
1 2
2 3
Length: 3, dtype: int64
In [7]: s2 = pd.Series(s1, index=["foo", "bar", "baz"])
In [8]: s2
Out[8]:
foo NaN
bar NaN
baz NaN
Length: 3, dtype: float64
已从 PeriodIndex 中移除已弃用的
day_of_year
API,请改用dayofyear
(GH 1723)在导入时不要将 NumPy 的 suppress printoption 修改为 True
DataFrame 的内部 HDF5 数据排列已转置。旧文件仍可由 HDFStore 读取 (GH 1834, GH 1824)
已移除旧有冗余代码: pandas.stats.misc.quantileTS
Period 表示使用 ISO8601 格式:按月、按日等 (GH 1776)
空的 DataFrame 列现在创建为 object dtype。这将防止在列的 dtype 依赖于是否存在数据(例如,SQL 查询是否有结果)的代码中发生一类 TypeError 错误 (GH 1783)
现在使用 ix 设置 DataFrame/Panel 的部分时会对齐输入 Series/DataFrame (GH 1630)
GroupBy
中的first
和last
方法不再丢弃非数值列 (GH 1809)解决了文本解析器中指定自定义 NA 值的不一致性。除非明确将
keep_default_na
设置为 false,否则 dict 类型的na_values
不再覆盖默认 NA 值 (GH 1657)DataFrame.dot
将不再进行数据对齐,并且也适用于 Series (GH 1915)
有关完整列表,请参阅完整发行说明或 GitHub 上的问题跟踪器。
贡献者#
共有 24 人为本次发布贡献了补丁。名字旁边带有“+”的人是首次贡献补丁。
Chang She
Christopher Whelan +
Dan Miller +
Daniel Shapiro +
Dieter Vandenbussche
Doug Coleman +
John-Colvin +
Johnny +
Joshua Leahy +
Lars Buitinck +
Mark O’Leary +
Martin Blais
MinRK +
Paul Ivanov +
Skipper Seabold
Spencer Lyon +
Taavi Burns +
Wes McKinney
Wouter Overmeire
Yaroslav Halchenko
lenolib +
tshauck +
y-p +
Øystein S. Haaland +