版本 0.14.0 (2014年5月31日)#
这是从 0.13.1 版本开始的一个主要发布,包含少量的 API 变更、几个新功能、增强、性能改进以及大量的错误修复。我们建议所有用户升级到此版本。
亮点包括
警告
在 0.14.0 版本中,所有基于 NDFrame
的容器都进行了重大的内部重构。在此之前,每个同类数据块都有自己的标签,需要额外小心才能使其与父容器的标签保持同步。这应该不会引起任何可见的用户/API 行为变更 (GH 6745)
API 变更#
read_excel
将 0 作为默认工作表 (GH 6573)iloc
现在将接受切片的越界索引器,例如超过被索引对象长度的值。这些将被排除。这将使 pandas 更符合 python/numpy 对越界值的索引行为。单个越界且会丢弃对象维度的索引器仍将引发IndexError
(GH 6296, GH 6299)。这可能导致一个空轴(例如返回一个空的 DataFrame)In [1]: dfl = pd.DataFrame(np.random.randn(5, 2), columns=list('AB')) In [2]: dfl Out[2]: A B 0 0.469112 -0.282863 1 -1.509059 -1.135632 2 1.212112 -0.173215 3 0.119209 -1.044236 4 -0.861849 -2.104569 [5 rows x 2 columns] In [3]: dfl.iloc[:, 2:3] Out[3]: Empty DataFrame Columns: [] Index: [0, 1, 2, 3, 4] [5 rows x 0 columns] In [4]: dfl.iloc[:, 1:3] Out[4]: B 0 -0.282863 1 -1.135632 2 -0.173215 3 -1.044236 4 -2.104569 [5 rows x 1 columns] In [5]: dfl.iloc[4:6] Out[5]: A B 4 -0.861849 -2.104569 [1 rows x 2 columns]
这些是越界选择
>>> dfl.iloc[[4, 5, 6]] IndexError: positional indexers are out-of-bounds >>> dfl.iloc[:, 4] IndexError: single positional indexer is out-of-bounds
负数起始、停止和步长值的切片更好地处理了边缘情况 (GH 6531)
df.iloc[:-len(df)]
现在为空df.iloc[len(df)::-1]
现在按倒序枚举所有元素
DataFrame.interpolate()
的关键字参数downcast
的默认值已从infer
更改为None
。这是为了保留原始 dtype,除非明确要求更改 (GH 6290)。将 dataframe 转换为 HTML 时,过去常常返回
Empty DataFrame
。这种特殊情况已被移除,现在改为返回带有列名称的头部 (GH 6062)。Series
和Index
现在在内部共享更多常见操作,例如factorize(),nunique(),value_counts()
现在也支持Index
类型。为了 API 一致性,Series.weekday
属性已从 Series 中移除。在 Series 上使用DatetimeIndex/PeriodIndex
方法现在将引发TypeError
。(GH 4551, GH 4056, GH 5519, GH 6380, GH 7206)。为
DateTimeIndex
/Timestamp
添加了is_month_start
,is_month_end
,is_quarter_start
,is_quarter_end
,is_year_start
,is_year_end
访问器,它们返回一个布尔数组,指示时间戳是否是DateTimeIndex
/Timestamp
定义的月/季/年的开始/结束 (GH 4565, GH 6998)pandas.eval()
/DataFrame.eval()
/DataFrame.query()
中的局部变量用法发生了变化 (GH 5987)。对于DataFrame
方法,有两件事发生了变化列名称现在优先于局部变量
局部变量必须明确引用。这意味着即使您有一个不是列的局部变量,您仍然必须使用
'@'
前缀来引用它。您可以有一个表达式,如
df.query('@a < a')
,而pandas
不会抱怨名称a
的歧义。顶层
pandas.eval()
函数不允许您使用'@'
前缀,并会提供错误消息提示。NameResolutionError
已移除,因为它不再必要。
定义并记录 query/eval 中列名与索引名的顺序 (GH 6676)
concat
现在会使用 Series 名称或按需对列进行编号来连接混合的 Series 和 DataFrames (GH 2385)。请参见 文档对
Index
类进行切片和高级/布尔索引操作,以及Index.delete()
和Index.drop()
方法将不再改变结果索引的类型 (GH 6440, GH 7040)In [6]: i = pd.Index([1, 2, 3, 'a', 'b', 'c']) In [7]: i[[0, 1, 2]] Out[7]: Index([1, 2, 3], dtype='object') In [8]: i.drop(['a', 'b', 'c']) Out[8]: Index([1, 2, 3], dtype='object')
之前,上述操作会返回
Int64Index
。如果您想手动执行此操作,请使用Index.astype()
In [9]: i[[0, 1, 2]].astype(np.int_) Out[9]: Index([1, 2, 3], dtype='int64')
set_index
不再将 MultiIndexes 转换为元组索引。例如,在旧版本中,此情况会返回一个 Index (GH 6459)# Old behavior, casted MultiIndex to an Index In [10]: tuple_ind Out[10]: Index([('a', 'c'), ('a', 'd'), ('b', 'c'), ('b', 'd')], dtype='object') In [11]: df_multi.set_index(tuple_ind) Out[11]: 0 1 (a, c) 0.471435 -1.190976 (a, d) 1.432707 -0.312652 (b, c) -0.720589 0.887163 (b, d) 0.859588 -0.636524 [4 rows x 2 columns] # New behavior In [12]: mi Out[12]: MultiIndex([('a', 'c'), ('a', 'd'), ('b', 'c'), ('b', 'd')], ) In [13]: df_multi.set_index(mi) Out[13]: 0 1 a c 0.471435 -1.190976 d 1.432707 -0.312652 b c -0.720589 0.887163 d 0.859588 -0.636524 [4 rows x 2 columns]
这也适用于向
set_index
传递多个索引# Old output, 2-level MultiIndex of tuples In [14]: df_multi.set_index([df_multi.index, df_multi.index]) Out[14]: 0 1 (a, c) (a, c) 0.471435 -1.190976 (a, d) (a, d) 1.432707 -0.312652 (b, c) (b, c) -0.720589 0.887163 (b, d) (b, d) 0.859588 -0.636524 [4 rows x 2 columns] # New output, 4-level MultiIndex In [15]: df_multi.set_index([df_multi.index, df_multi.index]) Out[15]: 0 1 a c a c 0.471435 -1.190976 d a d 1.432707 -0.312652 b c b c -0.720589 0.887163 d b d 0.859588 -0.636524 [4 rows x 2 columns]
在统计矩函数
rolling_cov
,rolling_corr
,ewmcov
,ewmcorr
,expanding_cov
,expanding_corr
中添加了pairwise
关键字,以允许计算滑动窗口协方差和相关矩阵 (GH 4950)。请参见文档中的 计算滑动成对协方差和相关性。In [1]: df = pd.DataFrame(np.random.randn(10, 4), columns=list('ABCD')) In [4]: covs = pd.rolling_cov(df[['A', 'B', 'C']], ....: df[['B', 'C', 'D']], ....: 5, ....: pairwise=True) In [5]: covs[df.index[-1]] Out[5]: B C D A 0.035310 0.326593 -0.505430 B 0.137748 -0.006888 -0.005383 C -0.006888 0.861040 0.020762
Series.iteritems()
现在是惰性的(返回迭代器而不是列表)。这是 0.14 版本之前文档中描述的行为。(GH 6760)为
Index
添加了nunique
和value_counts
函数,用于计算唯一元素。(GH 6734)stack
和unstack
现在当level
关键字引用Index
中的非唯一项时会引发ValueError
(之前会引发KeyError
)。(GH 6738)从
Series.sort
中删除了未使用的 order 参数;参数现在与Series.order
的顺序相同;添加na_position
参数以符合Series.order
(GH 6847)Series.order
的默认排序算法现在是quicksort
,以符合Series.sort
(和 numpy 默认值)为
Series.order/sort
添加了inplace
关键字,使它们互为逆操作 (GH 6859)DataFrame.sort
现在根据na_position
参数将 NaNs 放在排序的开头或结尾。(GH 3917)在
concat
中接受TextFileReader
,这影响了一个常见用户习惯用法 (GH 6583),这是 0.13.1 的一个回归为
Index
和Series
添加了factorize
函数以获取索引器和唯一值 (GH 7090)在混合了 Timestamp 和字符串类型对象的 DataFrame 上调用
describe
会返回一个不同的 Index (GH 7088)。之前,索引会意外地被排序。算术运算中,如果 **仅** 包含
bool
dtypes,则+
,-
和*
运算现在会发出警告,指示它们在 Python 空间中进行评估,其他所有运算都会引发错误 (GH 7011, GH 6762, GH 7015, GH 7210)>>> x = pd.Series(np.random.rand(10) > 0.5) >>> y = True >>> x + y # warning generated: should do x | y instead UserWarning: evaluating in Python space because the '+' operator is not supported by numexpr for the bool dtype, use '|' instead >>> x / y # this raises because it doesn't make sense NotImplementedError: operator '/' not implemented for bool dtypes
在
HDFStore
中,当找不到 key 或 selector 时,select_as_multiple
将始终引发KeyError
(GH 6177)df['col'] = value
和df.loc[:,'col'] = value
现在完全等价;之前.loc
不一定强制转换结果 Series 的 dtype (GH 6149)在空容器上,
dtypes
和ftypes
现在返回 dtype 为object
的 Series (GH 5740)如果没有提供目标路径或缓冲区,
df.to_csv
现在将返回 CSV 数据的字符串表示 (GH 6061)如果给定无效的
Series/Index
类型,pd.infer_freq()
现在将引发TypeError
(GH 6407, GH 6463)传递给
DataFame.sort_index
的元组将被解释为索引的层级,而不是要求一个元组列表 (GH 4370)所有 offset 操作现在都返回
Timestamp
类型(而不是 datetime),Business/Week 频率之前不正确 (GH 4069)to_excel
现在将np.inf
转换为字符串表示,可通过inf_rep
关键字参数自定义(Excel 没有原生的 inf 表示)(GH 6782)用
numpy.percentile
替换pandas.compat.scipy.scoreatpercentile
(GH 6810)在
datetime[ns]
Series 上调用.quantile
现在返回Timestamp
对象而不是np.datetime64
对象 (GH 6810)对于传递给
concat
的无效类型,将AssertionError
更改为TypeError
(GH 6583)当将迭代器作为
data
参数传递给DataFrame
时,引发TypeError
(GH 5357)
显示变更#
打印大型 DataFrame 的默认方式发生了变化。超过
max_rows
和/或max_columns
的 DataFrame 现在以居中截断的方式显示,这与pandas.Series
的打印方式一致 (GH 5603)。在以前的版本中,一旦达到维度限制,DataFrame 就会被截断,并且省略号 (...) 表示部分数据被切断。
在当前版本中,大型 DataFrame 会被居中截断,显示头部和尾部在两个维度上的预览。
允许
display.show_dimensions
选项设置为'truncate'
,以便仅在 frame 被截断时显示维度 (GH 6547)。display.show_dimensions
的默认值现在将是truncate
。这与 Series 显示长度的方式一致。In [16]: dfd = pd.DataFrame(np.arange(25).reshape(-1, 5), ....: index=[0, 1, 2, 3, 4], ....: columns=[0, 1, 2, 3, 4]) ....: # show dimensions since this is truncated In [17]: with pd.option_context('display.max_rows', 2, 'display.max_columns', 2, ....: 'display.show_dimensions', 'truncate'): ....: print(dfd) ....: 0 ... 4 0 0 ... 4 .. .. ... .. 4 20 ... 24 [5 rows x 5 columns] # will not show dimensions since it is not truncated In [18]: with pd.option_context('display.max_rows', 10, 'display.max_columns', 40, ....: 'display.show_dimensions', 'truncate'): ....: print(dfd) ....: 0 1 2 3 4 0 0 1 2 3 4 1 5 6 7 8 9 2 10 11 12 13 14 3 15 16 17 18 19 4 20 21 22 23 24
修复了当
display.max_rows
小于 Series 长度时,MultiIndexed Series 显示中的一个回归问题 (GH 7101)修复了当
large_repr
设置为 'info' 时,截断的 Series 或 DataFrame 的 HTML repr 不显示类名的问题 (GH 7105)DataFrame.info()
中的verbose
关键字,用于控制是否缩短info
表示,现在默认为None
。这将遵循display.max_info_columns
中的全局设置。全局设置可以通过verbose=True
或verbose=False
进行覆盖。修复了
info
repr 未遵循display.max_info_columns
设置的问题 (GH 6939)Timestamp __repr__ 中现在包含 Offset/freq 信息 (GH 4553)
文本解析 API 变更#
read_csv()
/read_table()
现在对于无效选项会更“嘈杂”,而不是回退到 PythonParser
。
在
read_csv()
/read_table()
中,当同时指定sep
和delim_whitespace=True
时,引发ValueError
(GH 6607)在
read_csv()
/read_table()
中,当指定engine='c'
但包含不受支持的选项时,引发ValueError
(GH 6607)当回退到 python 解析器导致选项被忽略时,引发
ValueError
(GH 6607)当回退到 python 解析器且没有选项被忽略时,生成
ParserWarning
(GH 6607)在
read_csv()
/read_table()
中,如果未指定其他 C 不支持的选项,则将sep='\s+'
转换为delim_whitespace=True
(GH 6607)
GroupBy API 变更#
一些 groupby 方法的行为更加一致
groupby
head
和tail
现在更像filter
而不是聚合In [1]: df = pd.DataFrame([[1, 2], [1, 4], [5, 6]], columns=['A', 'B']) In [2]: g = df.groupby('A') In [3]: g.head(1) # filters DataFrame Out[3]: A B 0 1 2 2 5 6 In [4]: g.apply(lambda x: x.head(1)) # used to simply fall-through Out[4]: A B A 1 0 1 2 5 2 5 6
groupby head 和 tail 遵循列选择
In [19]: g[['B']].head(1) Out[19]: B 0 2 2 6 [2 rows x 1 columns]
groupby
nth
现在默认为 reduction(归约);过滤可以通过传入as_index=False
来实现。同时有一个可选的dropna
参数来忽略 NaN。请参见 文档。归约
In [19]: df = pd.DataFrame([[1, np.nan], [1, 4], [5, 6]], columns=['A', 'B']) In [20]: g = df.groupby('A') In [21]: g.nth(0) Out[21]: A B 0 1 NaN 2 5 6.0 [2 rows x 2 columns] # this is equivalent to g.first() In [22]: g.nth(0, dropna='any') Out[22]: A B 1 1 4.0 2 5 6.0 [2 rows x 2 columns] # this is equivalent to g.last() In [23]: g.nth(-1, dropna='any') Out[23]: A B 1 1 4.0 2 5 6.0 [2 rows x 2 columns]
过滤
In [24]: gf = df.groupby('A', as_index=False) In [25]: gf.nth(0) Out[25]: A B 0 1 NaN 2 5 6.0 [2 rows x 2 columns] In [26]: gf.nth(0, dropna='any') Out[26]: A B 1 1 4.0 2 5 6.0 [2 rows x 2 columns]
对于非 cython 函数,groupby 现在不会返回被分组的列 (GH 5610, GH 5614, GH 6732),因为该列已经是索引
In [27]: df = pd.DataFrame([[1, np.nan], [1, 4], [5, 6], [5, 8]], columns=['A', 'B']) In [28]: g = df.groupby('A') In [29]: g.count() Out[29]: B A 1 1 5 2 [2 rows x 1 columns] In [30]: g.describe() Out[30]: B count mean std min 25% 50% 75% max A 1 1.0 4.0 NaN 4.0 4.0 4.0 4.0 4.0 5 2.0 7.0 1.414214 6.0 6.5 7.0 7.5 8.0 [2 rows x 8 columns]
传递
as_index
会将分组列保留在原地(这在 0.14.0 中没有变化)In [31]: df = pd.DataFrame([[1, np.nan], [1, 4], [5, 6], [5, 8]], columns=['A', 'B']) In [32]: g = df.groupby('A', as_index=False) In [33]: g.count() Out[33]: A B 0 1 1 1 5 2 [2 rows x 2 columns] In [34]: g.describe() Out[34]: A B count mean std min 25% 50% 75% max 0 1 1.0 4.0 NaN 4.0 4.0 4.0 4.0 4.0 1 5 2.0 7.0 1.414214 6.0 6.5 7.0 7.5 8.0 [2 rows x 9 columns]
允许通过
pd.Grouper
指定更复杂的 groupby,例如同时按时间和字符串字段进行分组。请参见 文档。(GH 3794)在执行 groupby 操作时,更好地传播/保留 Series 名称
SQL#
SQL 读取和写入函数现在通过 SQLAlchemy 支持更多数据库类型 (GH 2717, GH 4163, GH 5950, GH 6292)。可以使用 SQLAlchemy 支持的所有数据库,例如 PostgreSQL、MySQL、Oracle、Microsoft SQL Server(请参阅 SQLAlchemy 文档中的 包含的 dialects)。
未来只支持 sqlite3 的 DBAPI 连接对象提供功能。'mysql'
类型已废弃。
引入了新函数 read_sql_query()
和 read_sql_table()
。函数 read_sql()
作为其他两个函数的方便包装器被保留,并将根据提供的输入(数据库表名或 sql 查询)委托给特定函数。
实际上,您必须为 sql 函数提供一个 SQLAlchemy engine
。要使用 SQLAlchemy 连接,您需要使用 create_engine()
函数从数据库 URI 创建一个引擎对象。对于要连接的每个数据库,您只需要创建一个引擎。对于内存中的 sqlite 数据库
In [35]: from sqlalchemy import create_engine
# Create your connection.
In [36]: engine = create_engine('sqlite:///:memory:')
然后可以使用此 engine
从此数据库写入或读取数据
In [37]: df = pd.DataFrame({'A': [1, 2, 3], 'B': ['a', 'b', 'c']})
In [38]: df.to_sql(name='db_table', con=engine, index=False)
Out[38]: 3
您可以通过指定表名从数据库读取数据
In [39]: pd.read_sql_table('db_table', engine)
Out[39]:
A B
0 1 a
1 2 b
2 3 c
[3 rows x 2 columns]
或者通过指定 sql 查询
In [40]: pd.read_sql_query('SELECT * FROM db_table', engine)
Out[40]:
A B
0 1 a
1 2 b
2 3 c
[3 rows x 2 columns]
sql 函数的其他一些增强功能包括
支持写入索引。这可以通过
index
关键字控制(默认为 True)。使用
index_label
指定写入索引时使用的列标签。在
read_sql_query()
和read_sql_table()
中,使用parse_dates
关键字指定要解析为日期时间的字符串列。
警告
一些现有函数或函数别名已被弃用,并将在未来版本中移除。这包括:tquery
, uquery
, read_frame
, frame_query
, write_frame
。
警告
使用 DBAPI 连接对象时对 ‘mysql’ 方言的支持已被弃用。MySQL 将在 SQLAlchemy 引擎的支持下继续使用 (GH 6900)。
使用切片器进行多级索引#
在 0.14.0 版本中,我们添加了一种对 MultiIndexed 对象进行切片的新方法。您可以通过提供多个索引器来对 MultiIndex 进行切片。
您可以提供任何选择器,就像按标签索引一样,请参阅 按标签选择,包括切片、标签列表、标签和布尔索引器。
您可以使用 slice(None)
选择该级别的所有内容。您无需指定所有更深层级,它们将被隐式视为 slice(None)
。
像往常一样,由于这是标签索引,切片器的 两端 都包含在内。
请参阅 文档,另请参阅相关问题 (GH 6134, GH 4036, GH 3057, GH 2598, GH 5641, GH 7106)
警告
您应该在
.loc
指定器中指定所有轴,即 索引 和 列 的索引器。在某些模糊情况下,传入的索引器可能会被误解为索引 两个 轴,而不是(例如)用于行的 MultiIndex。您应该这样做
>>> df.loc[(slice('A1', 'A3'), ...), :] # noqa: E901
rather than this:
>>> df.loc[(slice('A1', 'A3'), ...)] # noqa: E901
警告
您需要确保选择的轴完全按字典序排序!
In [41]: def mklbl(prefix, n):
....: return ["%s%s" % (prefix, i) for i in range(n)]
....:
In [42]: index = pd.MultiIndex.from_product([mklbl('A', 4),
....: mklbl('B', 2),
....: mklbl('C', 4),
....: mklbl('D', 2)])
....:
In [43]: columns = pd.MultiIndex.from_tuples([('a', 'foo'), ('a', 'bar'),
....: ('b', 'foo'), ('b', 'bah')],
....: names=['lvl0', 'lvl1'])
....:
In [44]: df = pd.DataFrame(np.arange(len(index) * len(columns)).reshape((len(index),
....: len(columns))),
....: index=index,
....: columns=columns).sort_index().sort_index(axis=1)
....:
In [45]: df
Out[45]:
lvl0 a b
lvl1 bar foo bah foo
A0 B0 C0 D0 1 0 3 2
D1 5 4 7 6
C1 D0 9 8 11 10
D1 13 12 15 14
C2 D0 17 16 19 18
... ... ... ... ...
A3 B1 C1 D1 237 236 239 238
C2 D0 241 240 243 242
D1 245 244 247 246
C3 D0 249 248 251 250
D1 253 252 255 254
[64 rows x 4 columns]
使用切片、列表和标签进行基本的 MultiIndex 切片。
In [46]: df.loc[(slice('A1', 'A3'), slice(None), ['C1', 'C3']), :]
Out[46]:
lvl0 a b
lvl1 bar foo bah foo
A1 B0 C1 D0 73 72 75 74
D1 77 76 79 78
C3 D0 89 88 91 90
D1 93 92 95 94
B1 C1 D0 105 104 107 106
... ... ... ... ...
A3 B0 C3 D1 221 220 223 222
B1 C1 D0 233 232 235 234
D1 237 236 239 238
C3 D0 249 248 251 250
D1 253 252 255 254
[24 rows x 4 columns]
您可以使用 pd.IndexSlice
来创建这些切片的快捷方式
In [47]: idx = pd.IndexSlice
In [48]: df.loc[idx[:, :, ['C1', 'C3']], idx[:, 'foo']]
Out[48]:
lvl0 a b
lvl1 foo foo
A0 B0 C1 D0 8 10
D1 12 14
C3 D0 24 26
D1 28 30
B1 C1 D0 40 42
... ... ...
A3 B0 C3 D1 220 222
B1 C1 D0 232 234
D1 236 238
C3 D0 248 250
D1 252 254
[32 rows x 2 columns]
使用此方法可以在多个轴上同时执行相当复杂的多重选择。
In [49]: df.loc['A1', (slice(None), 'foo')]
Out[49]:
lvl0 a b
lvl1 foo foo
B0 C0 D0 64 66
D1 68 70
C1 D0 72 74
D1 76 78
C2 D0 80 82
... ... ...
B1 C1 D1 108 110
C2 D0 112 114
D1 116 118
C3 D0 120 122
D1 124 126
[16 rows x 2 columns]
In [50]: df.loc[idx[:, :, ['C1', 'C3']], idx[:, 'foo']]
Out[50]:
lvl0 a b
lvl1 foo foo
A0 B0 C1 D0 8 10
D1 12 14
C3 D0 24 26
D1 28 30
B1 C1 D0 40 42
... ... ...
A3 B0 C3 D1 220 222
B1 C1 D0 232 234
D1 236 238
C3 D0 248 250
D1 252 254
[32 rows x 2 columns]
使用布尔索引器,您可以提供与 值 相关的选择。
In [51]: mask = df[('a', 'foo')] > 200
In [52]: df.loc[idx[mask, :, ['C1', 'C3']], idx[:, 'foo']]
Out[52]:
lvl0 a b
lvl1 foo foo
A3 B0 C1 D1 204 206
C3 D0 216 218
D1 220 222
B1 C1 D0 232 234
D1 236 238
C3 D0 248 250
D1 252 254
[7 rows x 2 columns]
您还可以向 .loc
指定 axis
参数,以便在单个轴上解释传入的切片器。
In [53]: df.loc(axis=0)[:, :, ['C1', 'C3']]
Out[53]:
lvl0 a b
lvl1 bar foo bah foo
A0 B0 C1 D0 9 8 11 10
D1 13 12 15 14
C3 D0 25 24 27 26
D1 29 28 31 30
B1 C1 D0 41 40 43 42
... ... ... ... ...
A3 B0 C3 D1 221 220 223 222
B1 C1 D0 233 232 235 234
D1 237 236 239 238
C3 D0 249 248 251 250
D1 253 252 255 254
[32 rows x 4 columns]
此外,您可以使用这些方法 设置 值
In [54]: df2 = df.copy()
In [55]: df2.loc(axis=0)[:, :, ['C1', 'C3']] = -10
In [56]: df2
Out[56]:
lvl0 a b
lvl1 bar foo bah foo
A0 B0 C0 D0 1 0 3 2
D1 5 4 7 6
C1 D0 -10 -10 -10 -10
D1 -10 -10 -10 -10
C2 D0 17 16 19 18
... ... ... ... ...
A3 B1 C1 D1 -10 -10 -10 -10
C2 D0 241 240 243 242
D1 245 244 247 246
C3 D0 -10 -10 -10 -10
D1 -10 -10 -10 -10
[64 rows x 4 columns]
您也可以使用可对齐对象的右侧。
In [57]: df2 = df.copy()
In [58]: df2.loc[idx[:, :, ['C1', 'C3']], :] = df2 * 1000
In [59]: df2
Out[59]:
lvl0 a b
lvl1 bar foo bah foo
A0 B0 C0 D0 1 0 3 2
D1 5 4 7 6
C1 D0 9000 8000 11000 10000
D1 13000 12000 15000 14000
C2 D0 17 16 19 18
... ... ... ... ...
A3 B1 C1 D1 237000 236000 239000 238000
C2 D0 241 240 243 242
D1 245 244 247 246
C3 D0 249000 248000 251000 250000
D1 253000 252000 255000 254000
[64 rows x 4 columns]
绘图#
使用
DataFrame.plot
和kind='hexbin'
绘制六边形分箱图 (GH 5478),请参阅 文档。DataFrame.plot
和Series.plot
现在支持指定kind='area'
的面积图 (GH 6656),请参阅 文档使用
Series.plot
和DataFrame.plot
和kind='pie'
绘制饼图 (GH 6976),请参阅 文档。DataFrame
和Series
对象的.plot
方法现在支持绘制误差条 (GH 3796, GH 6834),请参阅 文档。DataFrame.plot
和Series.plot
现在支持table
关键字来绘制matplotlib.Table
,请参阅 文档。table
关键字可以接受以下值。False
: 不执行任何操作(默认)。True
: 使用调用plot
方法的DataFrame
或Series
绘制表格。数据将被转置以符合 matplotlib 的默认布局。DataFrame
或Series
: 使用传入的数据绘制 matplotlib.table。数据将按照 print 方法中显示的方式绘制(不会自动转置)。此外,还添加了辅助函数pandas.tools.plotting.table
,用于从DataFrame
和Series
创建表格,并将其添加到matplotlib.Axes
。
plot(legend='reverse')
现在将反转大多数图例类型的图例标签顺序。(GH 6014)折线图和面积图可以通过设置
stacked=True
进行堆叠 (GH 6656)以下关键字现在可用于
kind='bar'
和kind='barh'
的DataFrame.plot()
width
: 指定条形宽度。在以前的版本中,静态值 0.5 被传递给 matplotlib 并且无法覆盖。(GH 6604)align
: 指定条形对齐方式。默认值为center
(与 matplotlib 不同)。在以前的版本中,pandas 将align='edge'
传递给 matplotlib 并自行调整位置到center
,这导致align
关键字未能按预期应用。(GH 4525)position
: 指定条形图布局的相对对齐方式。从 0(左/底端)到 1(右/顶端)。默认值为 0.5(中心)。(GH 6604)
由于默认
align
值发生变化,条形图的坐标现在位于整数值(0.0, 1.0, 2.0 ...)上。这旨在使条形图与折线图位于相同的坐标上。但是,当您手动调整条形位置或绘图区域时,例如使用set_xlim
、set_ylim
等,条形图可能会出现意外差异。在这种情况下,请修改您的脚本以适应新的坐标。parallel_coordinates()
函数现在接受参数color
而不是colors
。为了提示旧的colors
参数在未来版本中将不再受支持,会引发FutureWarning
。(GH 6956)parallel_coordinates()
和andrews_curves()
函数现在接受位置参数frame
而不是data
。如果按名称使用旧的data
参数,会引发FutureWarning
。(GH 6956)DataFrame.boxplot()
现在支持layout
关键字 (GH 6769)DataFrame.boxplot()
有一个新的关键字参数return_type
。它接受'dict'`、
'axes'` 或
'both'`,当设置为
'both'` 时,会返回一个包含 matplotlib axes 和 matplotlib Lines 字典的命名元组。
之前版本的弃用/更改#
截至 0.14.0 版本,一些之前版本的弃用已经生效。
移除
DateRange
,转而使用DatetimeIndex
(GH 6816)移除
DataFrame.sort
中的column
关键字 (GH 4370)移除
set_eng_float_format()
中的precision
关键字 (GH 395)移除
DataFrame.to_string()
、DataFrame.to_latex()
和DataFrame.to_html()
中的force_unicode
关键字;这些函数默认以 unicode 编码 (GH 2224, GH 2225)移除
DataFrame.to_csv()
和DataFrame.to_string()
中的nanRep
关键字 (GH 275)移除
HDFStore.select_column()
中的unique
关键字 (GH 3256)移除
Timestamp.offset()
中的inferTimeRule
关键字 (GH 391)移除
get_data_yahoo()
和get_data_google()
中的name
关键字 ( commit b921d1a )移除
DatetimeIndex
构造函数中的offset
关键字 ( commit 3136390 )移除一些滚动矩统计函数(例如
rolling_sum()
)中的time_rule
(GH 1042)移除 numpy 数组上的负号
-
布尔运算,转而支持反转号~
,因为这将在 numpy 1.9 中被弃用 (GH 6960)
弃用#
pivot_table()
/DataFrame.pivot_table()
和crosstab()
函数现在接受参数index
和columns
,而不是rows
和cols
。为了提示旧的rows
和cols
参数在未来版本中将不再受支持,会引发FutureWarning
(GH 5505)DataFrame.drop_duplicates()
和DataFrame.duplicated()
方法现在接受参数subset
而不是cols
,以便更好地与DataFrame.dropna()
对齐。为了提示旧的cols
参数在未来版本中将不再受支持,会引发FutureWarning
(GH 6680)DataFrame.to_csv()
和DataFrame.to_excel()
函数现在接受参数columns
而不是cols
。为了提示旧的cols
参数在未来版本中将不再受支持,会引发FutureWarning
(GH 6645)当与标量索引器和非浮点 Index 一起使用时,索引器将发出
FutureWarning
警告 (GH 4892, GH 6960)# non-floating point indexes can only be indexed by integers / labels In [1]: pd.Series(1, np.arange(5))[3.0] pandas/core/index.py:469: FutureWarning: scalar indexers for index type Int64Index should be integers and not floating point Out[1]: 1 In [2]: pd.Series(1, np.arange(5)).iloc[3.0] pandas/core/index.py:469: FutureWarning: scalar indexers for index type Int64Index should be integers and not floating point Out[2]: 1 In [3]: pd.Series(1, np.arange(5)).iloc[3.0:4] pandas/core/index.py:527: FutureWarning: slice indexers when using iloc should be integers and not floating point Out[3]: 3 1 dtype: int64 # these are Float64Indexes, so integer or floating point is acceptable In [4]: pd.Series(1, np.arange(5.))[3] Out[4]: 1 In [5]: pd.Series(1, np.arange(5.))[3.0] Out[6]: 1
Numpy 1.9 关于弃用警告的兼容性 (GH 6960)
Panel.shift()
现在具有与DataFrame.shift()
匹配的函数签名。旧的位置参数lags
已更改为关键字参数periods
,默认值为 1。如果按名称使用旧参数lags
,会引发FutureWarning
。(GH 6910)factorize()
的order
关键字参数将被移除。(GH 6926)。移除
DataFrame.xs()
、Panel.major_xs()
和Panel.minor_xs()
中的copy
关键字。如果可能,将返回一个视图,否则将创建一个副本。以前用户可能认为copy=False
会始终返回一个视图。(GH 6894)parallel_coordinates()
函数现在接受参数color
而不是colors
。为了提示旧的colors
参数在未来版本中将不再受支持,会引发FutureWarning
。(GH 6956)parallel_coordinates()
和andrews_curves()
函数现在接受位置参数frame
而不是data
。如果按名称使用旧的data
参数,会引发FutureWarning
。(GH 6956)使用 DBAPI 连接对象时对 ‘mysql’ 方言的支持已被弃用。MySQL 将在 SQLAlchemy 引擎的支持下继续使用 (GH 6900)。
以下
io.sql
函数已被弃用:tquery
,uquery
,read_frame
,frame_query
,write_frame
。describe()
中的percentile_width
关键字参数已被弃用。请改用percentiles
关键字,该关键字接受要显示的百分位数列表。默认输出保持不变。在未来版本中,
boxplot()
的默认返回类型将从 dict 更改为 matplotlib Axes。您现在可以通过将return_type='axes'
传递给 boxplot 来使用未来的行为。
已知问题#
OpenPyXL 2.0.0 破坏了向后兼容性 (GH 7169)
增强功能#
如果传入一个元组字典,DataFrame 和 Series 将创建一个 MultiIndex 对象,请参阅 文档 (GH 3323)
In [60]: pd.Series({('a', 'b'): 1, ('a', 'a'): 0, ....: ('a', 'c'): 2, ('b', 'a'): 3, ('b', 'b'): 4}) ....: Out[60]: a b 1 a 0 c 2 b a 3 b 4 Length: 5, dtype: int64 In [61]: pd.DataFrame({('a', 'b'): {('A', 'B'): 1, ('A', 'C'): 2}, ....: ('a', 'a'): {('A', 'C'): 3, ('A', 'B'): 4}, ....: ('a', 'c'): {('A', 'B'): 5, ('A', 'C'): 6}, ....: ('b', 'a'): {('A', 'C'): 7, ('A', 'B'): 8}, ....: ('b', 'b'): {('A', 'D'): 9, ('A', 'B'): 10}}) ....: Out[61]: a b b a c a b A B 1.0 4.0 5.0 8.0 10.0 C 2.0 3.0 6.0 7.0 NaN D NaN NaN NaN NaN 9.0 [3 rows x 5 columns]
向
Index
添加了sym_diff
方法 (GH 5543)DataFrame.to_latex
现在接受 longtable 关键字,如果设置为 True,将在 longtable 环境中返回一个表格。(GH 6617)在
DataFrame.to_latex
中添加关闭转义的选项 (GH 6472)如果未指定
sep
关键字,pd.read_clipboard
将尝试检测从电子表格复制的数据并相应地进行解析。(GH 6223)将单个索引的 DataFrame 与 MultiIndexed DataFrame 合并 (GH 3662)
请参阅 文档。目前尚不支持同时在左侧和右侧合并 MultiIndex DataFrame。
In [62]: household = pd.DataFrame({'household_id': [1, 2, 3], ....: 'male': [0, 1, 0], ....: 'wealth': [196087.3, 316478.7, 294750] ....: }, ....: columns=['household_id', 'male', 'wealth'] ....: ).set_index('household_id') ....: In [63]: household Out[63]: male wealth household_id 1 0 196087.3 2 1 316478.7 3 0 294750.0 [3 rows x 2 columns] In [64]: portfolio = pd.DataFrame({'household_id': [1, 2, 2, 3, 3, 3, 4], ....: 'asset_id': ["nl0000301109", ....: "nl0000289783", ....: "gb00b03mlx29", ....: "gb00b03mlx29", ....: "lu0197800237", ....: "nl0000289965", ....: np.nan], ....: 'name': ["ABN Amro", ....: "Robeco", ....: "Royal Dutch Shell", ....: "Royal Dutch Shell", ....: "AAB Eastern Europe Equity Fund", ....: "Postbank BioTech Fonds", ....: np.nan], ....: 'share': [1.0, 0.4, 0.6, 0.15, 0.6, 0.25, 1.0] ....: }, ....: columns=['household_id', 'asset_id', 'name', 'share'] ....: ).set_index(['household_id', 'asset_id']) ....: In [65]: portfolio Out[65]: name share household_id asset_id 1 nl0000301109 ABN Amro 1.00 2 nl0000289783 Robeco 0.40 gb00b03mlx29 Royal Dutch Shell 0.60 3 gb00b03mlx29 Royal Dutch Shell 0.15 lu0197800237 AAB Eastern Europe Equity Fund 0.60 nl0000289965 Postbank BioTech Fonds 0.25 4 NaN NaN 1.00 [7 rows x 2 columns] In [66]: household.join(portfolio, how='inner') Out[66]: male ... share household_id asset_id ... 1 nl0000301109 0 ... 1.00 2 nl0000289783 1 ... 0.40 gb00b03mlx29 1 ... 0.60 3 gb00b03mlx29 0 ... 0.15 lu0197800237 0 ... 0.60 nl0000289965 0 ... 0.25 [6 rows x 4 columns]
现在在使用
DataFrame.to_csv
时可以指定quotechar
、doublequote
和escapechar
。(GH 5414, GH 4528)使用布尔关键字参数
sort_remaining
,仅按 MultiIndex 指定的级别进行部分排序。(GH 3984)向
TimeStamp
和DatetimeIndex
添加了to_julian_date
方法。儒略日期主要用于天文学,表示自公元前 4713 年 1 月 1 日中午以来的天数。由于 pandas 中使用纳秒定义时间,因此可用的实际日期范围是公元 1678 年到公元 2262 年。(GH 4041)DataFrame.to_stata
现在将检查数据与 Stata 数据类型的兼容性,并在需要时进行向上转换。如果无法进行无损向上转换,将发出警告 (GH 6327)DataFrame.to_stata
和StataWriter
将接受关键字参数 time_stamp 和 data_label,这些参数允许在创建文件时设置时间戳和数据集标签。(GH 6545)pandas.io.gbq
现在可以正确处理读取 unicode 字符串。(GH 5940)Float64Index
现在由float64
dtype ndarray 支持,而不是object
dtype 数组 (GH 6471)。实现了
Panel.pct_change
方法 (GH 6904)向滚动矩函数添加了
how
选项,用于指定如何处理重采样;rolling_max()
默认使用 max,rolling_min()
默认使用 min,所有其他函数默认使用 mean (GH 6297)CustomBusinessMonthBegin
和CustomBusinessMonthEnd
现在可用 (GH 6866)Series.quantile()
和DataFrame.quantile()
现在接受一个分位数数组。describe()
现在接受一个百分位数数组,以包含在汇总统计信息中 (GH 4196)pivot_table
现在可以通过index
和columns
关键字接受Grouper
(GH 6913)In [67]: import datetime In [68]: df = pd.DataFrame({ ....: 'Branch': 'A A A A A B'.split(), ....: 'Buyer': 'Carl Mark Carl Carl Joe Joe'.split(), ....: 'Quantity': [1, 3, 5, 1, 8, 1], ....: 'Date': [datetime.datetime(2013, 11, 1, 13, 0), ....: datetime.datetime(2013, 9, 1, 13, 5), ....: datetime.datetime(2013, 10, 1, 20, 0), ....: datetime.datetime(2013, 10, 2, 10, 0), ....: datetime.datetime(2013, 11, 1, 20, 0), ....: datetime.datetime(2013, 10, 2, 10, 0)], ....: 'PayDay': [datetime.datetime(2013, 10, 4, 0, 0), ....: datetime.datetime(2013, 10, 15, 13, 5), ....: datetime.datetime(2013, 9, 5, 20, 0), ....: datetime.datetime(2013, 11, 2, 10, 0), ....: datetime.datetime(2013, 10, 7, 20, 0), ....: datetime.datetime(2013, 9, 5, 10, 0)]}) ....: In [69]: df Out[69]: Branch Buyer Quantity Date PayDay 0 A Carl 1 2013-11-01 13:00:00 2013-10-04 00:00:00 1 A Mark 3 2013-09-01 13:05:00 2013-10-15 13:05:00 2 A Carl 5 2013-10-01 20:00:00 2013-09-05 20:00:00 3 A Carl 1 2013-10-02 10:00:00 2013-11-02 10:00:00 4 A Joe 8 2013-11-01 20:00:00 2013-10-07 20:00:00 5 B Joe 1 2013-10-02 10:00:00 2013-09-05 10:00:00 [6 rows x 5 columns]
In [75]: df.pivot_table(values='Quantity', ....: index=pd.Grouper(freq='M', key='Date'), ....: columns=pd.Grouper(freq='M', key='PayDay'), ....: aggfunc="sum") Out[75]: PayDay 2013-09-30 2013-10-31 2013-11-30 Date 2013-09-30 NaN 3.0 NaN 2013-10-31 6.0 NaN 1.0 2013-11-30 NaN 9.0 NaN [3 rows x 3 columns]
字符串数组可以按指定宽度换行 (
str.wrap
) (GH 6999)为 Series 添加了
nsmallest()
和Series.nlargest()
方法,请参阅 文档 (GH 3960)PeriodIndex
完全支持部分字符串索引,类似于DatetimeIndex
(GH 7043)In [76]: prng = pd.period_range('2013-01-01 09:00', periods=100, freq='H') In [77]: ps = pd.Series(np.random.randn(len(prng)), index=prng) In [78]: ps Out[78]: 2013-01-01 09:00 0.015696 2013-01-01 10:00 -2.242685 2013-01-01 11:00 1.150036 2013-01-01 12:00 0.991946 2013-01-01 13:00 0.953324 ... 2013-01-05 08:00 0.285296 2013-01-05 09:00 0.484288 2013-01-05 10:00 1.363482 2013-01-05 11:00 -0.781105 2013-01-05 12:00 -0.468018 Freq: H, Length: 100, dtype: float64 In [79]: ps['2013-01-02'] Out[79]: 2013-01-02 00:00 0.553439 2013-01-02 01:00 1.318152 2013-01-02 02:00 -0.469305 2013-01-02 03:00 0.675554 2013-01-02 04:00 -1.817027 ... 2013-01-02 19:00 0.036142 2013-01-02 20:00 -2.074978 2013-01-02 21:00 0.247792 2013-01-02 22:00 -0.897157 2013-01-02 23:00 -0.136795 Freq: H, Length: 24, dtype: float64
使用 xlrd >= 0.9.3 时,
read_excel
现在可以读取 Excel 日期和时间中的毫秒 (GH 5945)pd.stats.moments.rolling_var
现在使用 Welford 方法以提高数值稳定性 (GH 6817)pd.expanding_apply 和 pd.rolling_apply 现在接受传递给 func 的 args 和 kwargs (GH 6289)
DataFrame.rank()
现在有了百分比排序选项 (GH 5971)Series.rank()
现在有了百分比排序选项 (GH 5971)Series.rank()
和DataFrame.rank()
现在接受method='dense'
用于无间隙排序 (GH 6514)支持使用 xlwt 传递
encoding
(GH 3710)重构 Block 类,移除
Block.items
属性,以避免项目处理中的重复 (GH 6745, GH 6988)。测试语句已更新,使用专用断言 (GH 6175)
性能#
使用
DatetimeConverter
将DatetimeIndex
转换为浮点序数时性能提升 (GH 6636)DataFrame.shift
的性能提升 (GH 5609)对 MultiIndexed Series 进行索引时的性能提升 (GH 5567)
单 dtyped 索引的性能提升 (GH 6484)
通过移除错误的缓存(例如 MonthEnd,BusinessMonthEnd),提高了某些偏移量构建 DataFrame 的性能 (GH 6479)
提高
CustomBusinessDay
的性能 (GH 6584)从可迭代对象读取指定行数时,
DataFrame.from_records
的性能提升 (GH 6700)整数 dtypes 的 timedelta 转换性能提升 (GH 6754)
提高了兼容 pickle 的性能 (GH 6899)
通过优化
take_2d
,提高了某些 reindexing 操作的性能 (GH 6749)GroupBy.count()
现在使用 Cython 实现,对于大量组的性能大大提升 (GH 7016)。
实验性特性#
0.14.0 中没有实验性变更
Bug 修复#
索引与数据不匹配时 Series ValueError 的错误 (GH 6532)
防止 HDFStore 表格格式不支持 MultiIndex 导致的段错误 (GH 1848)
pd.DataFrame.sort_index
中当ascending=False
时 mergesort 不稳定导致的错误 (GH 6399)pd.tseries.frequencies.to_offset
参数带有前导零时的错误 (GH 6391)对于浅克隆/从 tarball 安装的开发版本,版本字符串生成错误 (GH 6127)
当年份使用
Timestamp
/to_datetime
进行时区解析不一致 (GH 5958)大型表达式的类型提升失败导致的
eval
错误 (GH 6205)使用
inplace=True
进行插值时的错误 (GH 6281)HDFStore.remove
现在处理 start 和 stop (GH 6177)HDFStore.select_as_multiple
处理 start 和 stop 的方式与select
相同 (GH 6177)HDFStore.select_as_coordinates
和select_column
在where
子句导致过滤器时起作用 (GH 6177)非唯一索引连接的回归错误 (GH 6329)
使用单个函数和混合类型框进行 groupby
agg
的问题 (GH 6337)传递非
bool
的to_replace
参数时,DataFrame.replace()
中的错误 (GH 6332)尝试在 MultiIndex 赋值的不同级别上对齐时引发错误 (GH 3738)
通过布尔索引设置复杂 dtypes 的错误 (GH 6345)
当 TimeGrouper/resample 遇到非单调 DatetimeIndex 时,会返回无效结果的错误 (GH 4161)
TimeGrouper/resample 中索引名称传播的错误 (GH 4161)
TimeGrouper 具有与其余 groupers 更兼容的 API(例如,缺少
groups
) (GH 3881)使用 TimeGrouper 进行多重分组时,依赖于目标列顺序的错误 (GH 6764)
解析包含可能令牌(如
'&'
)的字符串时pd.eval
中的错误 (GH 6351)正确处理 Panel 中
-inf
位置的错误,当除以整数 0 时 (GH 6178)带有
axis=1
的DataFrame.shift
曾引发错误 (GH 6371)禁用了剪贴板测试,直到发布时(使用
nosetests -A disabled
在本地运行) (GH 6048)。传递包含不在要替换的值中的键的嵌套
dict
时,DataFrame.replace()
中的错误 (GH 6342)str.match
忽略了 na 标志 (GH 6609)。使用未合并的重复列进行 take 操作时的错误 (GH 6240)
插值改变 dtypes 的错误 (GH 6290)
Series.get
中的错误,使用了有缺陷的访问方法 (GH 6383)hdfstore 查询形式
where=[('date', '>=', datetime(2013,1,1)), ('date', '<=', datetime(2014,1,1))]
中的错误 (GH 6313)带有重复索引的
DataFrame.dropna
中的错误 (GH 6355)从 0.12 版本开始,带有嵌入式列表式对象的链式 getitem 索引的回归错误 (GH 6394)
带有 nans 的
Float64Index
比较不正确 (GH 6401)包含字符
@
的字符串的eval
/query
表达式现在可以工作 (GH 6366)。在指定
method
且存在一些 nan 值时,Series.reindex
中的错误不一致(在 resample 上注意到) (GH 6418)DataFrame.replace()
中的错误,嵌套字典错误地依赖于字典键值顺序 (GH 5338)。与空对象连接时的性能问题 (GH 3259)
澄清带有
NaN
值的Index
对象的sym_diff
排序 (GH 6444)以
DatetimeIndex
作为输入时MultiIndex.from_product
中的回归错误 (GH 6439)传递非默认索引时
str.extract
中的错误 (GH 6348)传递
pat=None
和n=1
时str.split
中的错误 (GH 6466)传递
"F-F_Momentum_Factor"
和data_source="famafrench"
时io.data.DataReader
中的错误 (GH 6460)timedelta64[ns]
Series 求和的错误 (GH 6462)带有时区和某些偏移量时
resample
的错误 (GH 6397)带有重复索引的 Series 上
iat/iloc
的错误 (GH 6493)read_html
中的错误,其中 nan 被错误地用于指示文本中的缺失值。应使用空字符串与 pandas 的其余部分保持一致 (GH 5129)。read_html
测试中的错误,重定向的无效 URL 会导致一个测试失败 (GH 6445)。在非唯一索引上使用
.loc
进行多轴索引的错误 (GH 6504)导致在 DataFrame 列轴上进行切片索引时
_ref_locs
损坏的错误 (GH 6525)从 0.13 版本开始,在创建 Series 时处理 numpy
datetime64
非 ns dtypes 的回归错误 (GH 6529)传递给
set_index
的 MultiIndexes 的.names
属性现在得到保留 (GH 6459)。带有重复索引和可对齐 rhs 的 setitem 错误 (GH 6541)
在混合整数索引上使用
.loc
进行 setitem 的错误 (GH 6546)pd.read_stata
使用错误的数据类型和缺失值的错误 (GH 6327)DataFrame.to_stata
在某些情况下导致数据丢失,并且可能使用错误的数据类型和缺失值导出的错误 (GH 6335)StataWriter
将字符串列中的缺失值替换为空字符串 (GH 6802)Timestamp
加减操作中的类型不一致 (GH 6543)Timestamp 加减操作中频率保留的错误 (GH 4547)
Series.quantile
在object
dtype 上引发错误 (GH 6555)丢弃包含
nan
的级别时.xs
中的错误 (GH 6574)使用
method='bfill/ffill'
和datetime64[ns]
dtype 进行 fillna 时的错误 (GH 6587)使用混合 dtypes 进行 sql 写入可能导致数据丢失的错误 (GH 6509)
Series.pop
中的错误 (GH 6600)当位置索引器匹配对应轴的
Int64Index
且没有重新排序发生时,iloc
索引中的错误 (GH 6612)指定
limit
和value
时 fillna 中的错误当列名不是字符串时,
DataFrame.to_stata
中的错误 (GH 4558)与
np.compress
兼容性错误,体现在 (GH 6658) 中与非对齐 Series 的 rhs 进行二元操作的错误 (GH 6681)
DataFrame.to_stata
错误地处理 nan 值并忽略with_index
关键字参数的错误 (GH 6685)使用可整除频率时,resample 中额外 bin 的错误 (GH 4076)
传递自定义函数时,groupby 聚合一致性错误 (GH 6715)
当
how=None
且 resample 频率与轴频率相同时,resample 中的错误 (GH 5955)空数组向下转换推断的错误 (GH 6733)
稀疏容器上
obj.blocks
丢弃除最后一个相同 dtype 项目之外的所有项目的错误 (GH 6748)unpickling
NaT (NaTType)
的错误 (GH 4606)DataFrame.replace()
中的错误,即使regex=False
,regex 元字符也被视为 regex (GH 6777)。32 位平台上的 timedelta 操作错误 (GH 6808)
通过
.index
直接设置时区感知索引的错误 (GH 6785)expressions.py 中的错误,其中 numexpr 尝试评估算术操作 (GH 6762)。
Makefile 中使用
make clean
未移除 Cython 生成的 C 文件的错误 (GH 6768)numpy < 1.7.2 从
HDFStore
读取长字符串时的错误 (GH 6166)DataFrame._reduce
中非布尔值(0/1)整数被转换为布尔值的错误 (GH 6806)从 0.13 版本开始,对 datetime-like 使用
fillna
和 Series 的回归错误 (GH 6344)将
np.timedelta64
添加到带时区的DatetimeIndex
导致输出错误结果的错误 (GH 6818)DataFrame.replace()
中的错误,其中通过替换更改 dtype 只会替换值的第一次出现 (GH 6689)在构建
Period
时传递频率 'MS' 的错误消息更友好 (GH5332)当
max_rows=None
且 Series 行数超过 1000 行时,Series.__unicode__
中的错误 (GH 6863)groupby.get_group
不总是接受 datelike 的错误 (GH 5267)由
TimeGrouper
创建的groupBy.get_group
引发AttributeError
的错误 (GH 6914)DatetimeIndex.tz_localize
和DatetimeIndex.tz_convert
错误地转换NaT
的错误 (GH 5546)影响
NaT
的算术操作错误 (GH 6873)Series.str.extract
中,从单个组匹配生成的Series
未重命名为组名的错误设置
index=False
时忽略header
kwarg 的DataFrame.to_csv
错误 (GH 6186)DataFrame.plot
和Series.plot
中的错误,在重复绘制到同一轴时图例行为不一致 (GH 6678)在
concat
中接受TextFileReader
,这影响了一个常见的用户惯用法 (GH 6583)C 解析器中存在前导空格的错误 (GH 3374)
C 解析器中
delim_whitespace=True
和\r
分隔行的错误python 解析器中在列标题后一行显式指定 MultiIndex 的错误 (GH 6893)
Series.rank
和DataFrame.rank
中的错误,导致小于 1e-13 的小浮点数都获得相同的排名 (GH 6886)DataFrame.apply
中函数的错误,这些函数使用了*args
或**kwargs
并返回空结果 (GH 6952)32 位平台上 sum/mean 在溢出时的错误 (GH 6915)
将
Panel.shift
移动到NDFrame.slice_shift
并修复以遵从多种 dtype。 (GH 6959)在
DataFrame.plot
中,当只有单列时启用subplots=True
会引发TypeError
,而Series.plot
会引发AttributeError
的错误 (GH 6951)DataFrame.plot
在启用subplots
和kind=scatter
时绘制不必要坐标轴的错误 (GH 6951)从非 utf-8 编码文件系统读取
read_csv
的错误 (GH 6807)在设置/对齐时
iloc
的错误 (GH 6766)使用 unicode 值和前缀调用 get_dummies 时导致 UnicodeEncodeError 的错误 (GH 6885)
具有频率的时间序列图的光标显示错误 (GH 5453)
在使用
Float64Index
时,groupby.plot
中出现的错误 (GH 7025)如果无法从 Yahoo 下载期权数据,停止测试失败 (GH 7034)
parallel_coordinates
和radviz
中的错误,其中类列的重新排序可能导致颜色/类不匹配 (GH 6956)radviz
和andrews_curves
中的错误,其中多个 'color' 值被传递给绘图方法 (GH 6956)Float64Index.isin()
中的错误,其中包含nan
会使索引声称它们包含所有内容 (GH 7066)。DataFrame.boxplot
中的错误,它未能使用作为ax
参数传递的轴 (GH 3578)XlsxWriter
和XlwtWriter
实现中的错误,导致日期时间列格式化时没有时间 (GH 7075) 被传递给绘图方法read_fwf()
在colspec
中将None
视作常规 python 切片。现在,当colspec
包含None
时,它会从行首读取或读取到行尾(之前会引发TypeError
)链式索引和切片与缓存一致性相关的错误;向
NDFrame
添加_is_view
属性以正确预测视图;仅当xs
是实际的副本(而不是视图)时标记其is_copy
(GH 7084)从带有
dayfirst=True
的字符串 ndarray 创建 DatetimeIndex 的错误 (GH 5917)从
DatetimeIndex
创建的MultiIndex.from_arrays
未保留freq
和tz
的错误 (GH 7090)当
MultiIndex
包含PeriodIndex
时,unstack
引发ValueError
的错误 (GH 4342)boxplot
和hist
绘制不必要坐标轴的错误 (GH 6769)groupby.nth()
在使用越界索引器时的回归问题 (GH 6621)对日期时间值执行
quantile
的错误 (GH 6965)Dataframe.set_index
,reindex
和pivot
未保留DatetimeIndex
和PeriodIndex
属性的错误 (GH 3950, GH 5878, GH 6631)MultiIndex.get_level_values
未保留DatetimeIndex
和PeriodIndex
属性的错误 (GH 7092)Groupby
未保留tz
的错误 (GH 3950)PeriodIndex
部分字符串切片的错误 (GH 6716)截断的 Series 或 DataFrame 的 HTML repr 在
large_repr
设置为 'info' 时未显示类名称的错误 (GH 7105)DatetimeIndex
指定freq
时,当传递的值太短会引发ValueError
的错误 (GH 7098)修复了
info
repr 未遵循display.max_info_columns
设置的问题 (GH 6939)PeriodIndex
带有越界值的字符串切片错误 (GH 5407)修复了哈希表实现/factorizer 在调整大表大小时的内存错误 (GH 7157)
应用于 0 维对象数组时
isnull
的错误 (GH 7176)query
/eval
中的错误,其中全局常量未被正确查找 (GH 7178)使用
iloc
和多轴元组索引器识别越界位置列表索引器的错误 (GH 7189)ndim > 2 且使用 MultiIndex 的多轴索引错误 (GH 7199)
修复了无效的 eval/query 操作会导致栈溢出的错误 (GH 5198)
贡献者#
共有 94 人为本次发布贡献了补丁。名字旁有“+”的人是首次贡献补丁。
Acanthostega +
Adam Marcus +
Alex Gaudio
Alex Rothberg
AllenDowney +
Andrew Rosenfeld +
Andy Hayden
Antoine Mazières +
Benedikt Sauer
Brad Buran
Christopher Whelan
Clark Fitzgerald
DSM
Dale Jung
Dan Allan
Dan Birken
Daniel Waeber
David Jung +
David Stephens +
Douglas McNeil
Garrett Drapala
Gouthaman Balaraman +
Guillaume Poulin +
Jacob Howard +
Jacob Schaer
Jason Sexauer +
Jeff Reback
Jeff Tratner
Jeffrey Starr +
John David Reaver +
John McNamara
John W. O’Brien
Jonathan Chambers
Joris Van den Bossche
Julia Evans
Júlio +
K.-Michael Aye
Katie Atkinson +
Kelsey Jordahl
Kevin Sheppard +
Matt Wittmann +
Matthias Kuhn +
Max Grender-Jones +
Michael E. Gruen +
Mike Kelly
Nipun Batra +
Noah Spies +
PKEuS
Patrick O’Keeffe
Phillip Cloud
Pietro Battiston +
Randy Carnevale +
Robert Gibboni +
Skipper Seabold
SplashDance +
Stephan Hoyer +
Tim Cera +
Tobias Brandt
Todd Jennings +
Tom Augspurger
TomAugspurger
Yaroslav Halchenko
agijsberts +
akittredge
ankostis +
anomrake
anton-d +
bashtage +
benjamin +
bwignall
cgohlke +
chebee7i +
clham +
danielballan
hshimizu77 +
hugo +
immerrr
ischwabacher +
jaimefrio +
jreback
jsexauer +
kdiether +
michaelws +
mikebailey +
ojdo +
onesandzeroes +
phaebz +
ribonoous +
rockg
sinhrks +
unutbu
westurner
y-p
zach powers