版本 0.18.0(2016 年 3 月 13 日)#
这是 0.17.1 的主要版本,包括少量 API 更改、一些新功能、增强功能和性能改进以及大量错误修复。我们建议所有用户升级到此版本。
警告
numexpr
2.4.4 版现在将显示警告,并且由于一些错误行为而不能用作 pandas 的计算后端。这不会影响其他版本(>= 2.1 和 >= 2.4.6)。 (GH 12489)
亮点包括:
移动和扩展窗口函数现在是 Series 和 DataFrame 上的方法,类似于
.groupby
,请参见此处。添加对 a 的支持
RangeIndex
作为 的特殊形式Int64Index
以节省内存,请参阅此处。API 对方法进行了重大更改,
.resample
使其更像.groupby
,请参见此处。删除了对浮动位置索引的支持,该支持自 0.14.0 起已弃用。现在就这个提出来
TypeError
,看这里。read_sas
增强了读取文件的功能,sas7bdat
请参见此处。添加了.str.extractall() 方法,并对.str.extract() 方法 和.str.cat() 方法进行了 API 更改。
pd.test()
提供顶级鼻子测试运行机(GH 4327)。
v0.18.0 中的新增功能
新功能#
窗口函数现在是方法#
窗口函数已被重构为Series/DataFrame
对象上的方法,而不是现已弃用的顶级函数。这允许这些窗口类型函数具有与.groupby
.请参阅此处的完整文档(GH 11603、GH 12373)
In [1]: np.random.seed(1234)
In [2]: df = pd.DataFrame({'A': range(10), 'B': np.random.randn(10)})
In [3]: df
Out[3]:
A B
0 0 0.471435
1 1 -1.190976
2 2 1.432707
3 3 -0.312652
4 4 -0.720589
5 5 0.887163
6 6 0.859588
7 7 -0.636524
8 8 0.015696
9 9 -2.242685
[10 rows x 2 columns]
以前的行为:
In [8]: pd.rolling_mean(df, window=3)
FutureWarning: pd.rolling_mean is deprecated for DataFrame and will be removed in a future version, replace with
DataFrame.rolling(window=3,center=False).mean()
Out[8]:
A B
0 NaN NaN
1 NaN NaN
2 1 0.237722
3 2 -0.023640
4 3 0.133155
5 4 -0.048693
6 5 0.342054
7 6 0.370076
8 7 0.079587
9 8 -0.954504
新行为:
In [4]: r = df.rolling(window=3)
这些显示了描述性代表
In [5]: r
Out[5]: Rolling [window=3,center=False,axis=0,method=single]
通过制表符补全可用的方法和属性。
In [9]: r.<TAB> # noqa E225, E999
r.A r.agg r.apply r.count r.exclusions r.max r.median r.name r.skew r.sum
r.B r.aggregate r.corr r.cov r.kurt r.mean r.min r.quantile r.std r.var
这些方法对Rolling
对象本身进行操作
In [6]: r.mean()
Out[6]:
A B
0 NaN NaN
1 NaN NaN
2 1.0 0.237722
3 2.0 -0.023640
4 3.0 0.133155
5 4.0 -0.048693
6 5.0 0.342054
7 6.0 0.370076
8 7.0 0.079587
9 8.0 -0.954504
[10 rows x 2 columns]
他们提供 getitem 访问器
In [7]: r['A'].mean()
Out[7]:
0 NaN
1 NaN
2 1.0
3 2.0
4 3.0
5 4.0
6 5.0
7 6.0
8 7.0
9 8.0
Name: A, Length: 10, dtype: float64
以及多重聚合
In [8]: r.agg({'A': ['mean', 'std'],
...: 'B': ['mean', 'std']})
...:
Out[8]:
A B
mean std mean std
0 NaN NaN NaN NaN
1 NaN NaN NaN NaN
2 1.0 1.0 0.237722 1.327364
3 2.0 1.0 -0.023640 1.335505
4 3.0 1.0 0.133155 1.143778
5 4.0 1.0 -0.048693 0.835747
6 5.0 1.0 0.342054 0.920379
7 6.0 1.0 0.370076 0.871850
8 7.0 1.0 0.079587 0.750099
9 8.0 1.0 -0.954504 1.162285
[10 rows x 4 columns]
更改重命名#
Series.rename
除了更改标签的旧行为之外,现在还NDFrame.rename_axis
可以采用标量或类似列表的参数来更改 Series 或轴名称。 (GH 9494,GH 11965)
In [9]: s = pd.Series(np.random.randn(5))
In [10]: s.rename('newname')
Out[10]:
0 1.150036
1 0.991946
2 0.953324
3 -2.021255
4 -0.334077
Name: newname, Length: 5, dtype: float64
In [11]: df = pd.DataFrame(np.random.randn(5, 2))
In [12]: (df.rename_axis("indexname")
....: .rename_axis("columns_name", axis="columns"))
....:
Out[12]:
columns_name 0 1
indexname
0 0.002118 0.405453
1 0.289092 1.321158
2 -1.546906 -0.202646
3 -0.655969 0.193421
4 0.553439 1.318152
[5 rows x 2 columns]
新功能在方法链中运行良好。以前这些方法只接受将标签映射到新标签的函数或字典。对于函数或类似字典的值,这将继续像以前一样工作。
范围索引#
ARangeIndex
已添加到Int64Index
子类中,以支持常见用例的内存节省替代方案。这与 pythonrange
对象(在 python 2 中)有类似的实现xrange
,因为它只存储索引的开始、停止和步长值。它将透明地与用户 API 交互,并Int64Index
在需要时转换为。
现在,这将是对象的默认构造索引NDFrame
,而不是以前的Int64Index
. (GH 939、GH 12070、GH 12071、GH 12109、GH 12888)
以前的行为:
In [3]: s = pd.Series(range(1000))
In [4]: s.index
Out[4]:
Int64Index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
...
990, 991, 992, 993, 994, 995, 996, 997, 998, 999], dtype='int64', length=1000)
In [6]: s.index.nbytes
Out[6]: 8000
新行为:
In [13]: s = pd.Series(range(1000))
In [14]: s.index
Out[14]: RangeIndex(start=0, stop=1000, step=1)
In [15]: s.index.nbytes
Out[15]: 128
对 str.extract 的更改#
.str.extract方法采用带有捕获组的正则表达式,查找每个主题字符串中的第一个匹配项,并返回捕获组的内容 ( GH 11386 )。
在 v0.18.0 中,该expand
参数被添加到
extract
.
expand=False
:它返回Series
、Index
或DataFrame
,具体取决于主题和正则表达式模式(与 0.18.0 之前的行为相同)。expand=True
:它总是返回 aDataFrame
,从用户的角度来看,这更加一致且不易混淆。
当前默认值是expand=None
给出 aFutureWarning
并使用expand=False
。为了避免出现此警告,请明确指定expand
.
In [1]: pd.Series(['a1', 'b2', 'c3']).str.extract(r'[ab](\d)', expand=None)
FutureWarning: currently extract(expand=None) means expand=False (return Index/Series/DataFrame)
but in a future version of pandas this will be changed to expand=True (return DataFrame)
Out[1]:
0 1
1 2
2 NaN
dtype: object
使用一组提取正则表达式会返回一个 Series if
expand=False
。
In [16]: pd.Series(['a1', 'b2', 'c3']).str.extract(r'[ab](\d)', expand=False)
Out[16]:
0 1
1 2
2 NaN
Length: 3, dtype: object
它返回一个DataFrame
只有一列的 if expand=True
。
In [17]: pd.Series(['a1', 'b2', 'c3']).str.extract(r'[ab](\d)', expand=True)
Out[17]:
0
0 1
1 2
2 NaN
[3 rows x 1 columns]
使用Index
仅包含一个捕获组的正则表达式调用 an 会返回Index
if expand=False
。
In [18]: s = pd.Series(["a1", "b2", "c3"], ["A11", "B22", "C33"])
In [19]: s.index
Out[19]: Index(['A11', 'B22', 'C33'], dtype='object')
In [20]: s.index.str.extract("(?P<letter>[a-zA-Z])", expand=False)
Out[20]: Index(['A', 'B', 'C'], dtype='object', name='letter')
它返回一个DataFrame
只有一列的 if expand=True
。
In [21]: s.index.str.extract("(?P<letter>[a-zA-Z])", expand=True)
Out[21]:
letter
0 A
1 B
2 C
[3 rows x 1 columns]
Index
使用具有多个捕获组的正则表达式调用会引发ValueError
if expand=False
。
>>> s.index.str.extract("(?P<letter>[a-zA-Z])([0-9]+)", expand=False)
ValueError: only one regex group is supported with Index
它返回一个DataFrame
if expand=True
。
In [22]: s.index.str.extract("(?P<letter>[a-zA-Z])([0-9]+)", expand=True)
Out[22]:
letter 1
0 A 11
1 B 22
2 C 33
[3 rows x 2 columns]
总之,extract(expand=True)
始终DataFrame
为每个主题字符串返回一行,为每个捕获组返回一列。
添加 str.extractall #
添加了.str.extractall方法( GH 11386)。与 不同extract
,它仅返回第一个匹配项。
In [23]: s = pd.Series(["a1a2", "b1", "c1"], ["A", "B", "C"])
In [24]: s
Out[24]:
A a1a2
B b1
C c1
Length: 3, dtype: object
In [25]: s.str.extract(r"(?P<letter>[ab])(?P<digit>\d)", expand=False)
Out[25]:
letter digit
A a 1
B b 1
C NaN NaN
[3 rows x 2 columns]
该extractall
方法返回所有匹配项。
In [26]: s.str.extractall(r"(?P<letter>[ab])(?P<digit>\d)")
Out[26]:
letter digit
match
A 0 a 1
1 a 2
B 0 b 1
[3 rows x 2 columns]
对 str.cat 的更改#
该方法.str.cat()
连接 a 的成员Series
。之前,如果NaN
系列中存在值,则调用.str.cat()
它会返回NaN
,这与 API 的其余部分不同Series.str.*
。此行为已修改为NaN
默认忽略值。 (GH 11435)。
添加了一个新的、更友好的,ValueError
以防止错误地将 thesep
作为 arg 而不是作为 kwarg 提供。 (GH 11334)。
In [27]: pd.Series(['a', 'b', np.nan, 'c']).str.cat(sep=' ')
Out[27]: 'a b c'
In [28]: pd.Series(['a', 'b', np.nan, 'c']).str.cat(sep=' ', na_rep='?')
Out[28]: 'a b ? c'
In [2]: pd.Series(['a', 'b', np.nan, 'c']).str.cat(' ')
ValueError: Did you mean to supply a ``sep`` keyword?
类似日期时间的舍入#
DatetimeIndex
、Timestamp
、TimedeltaIndex
、Timedelta
已经获得了.round()
、.floor()
和.ceil()
日期时间类舍入、向下取整和向上取整的方法。 (GH 4314,GH 11963)
天真的日期时间
In [29]: dr = pd.date_range('20130101 09:12:56.1234', periods=3)
In [30]: dr
Out[30]:
DatetimeIndex(['2013-01-01 09:12:56.123400', '2013-01-02 09:12:56.123400',
'2013-01-03 09:12:56.123400'],
dtype='datetime64[ns]', freq='D')
In [31]: dr.round('s')
Out[31]:
DatetimeIndex(['2013-01-01 09:12:56', '2013-01-02 09:12:56',
'2013-01-03 09:12:56'],
dtype='datetime64[ns]', freq=None)
# Timestamp scalar
In [32]: dr[0]
Out[32]: Timestamp('2013-01-01 09:12:56.123400')
In [33]: dr[0].round('10s')
Out[33]: Timestamp('2013-01-01 09:13:00')
Tz-aware 在当地时间是圆形的、有地板的和有天花板的
In [34]: dr = dr.tz_localize('US/Eastern')
In [35]: dr
Out[35]:
DatetimeIndex(['2013-01-01 09:12:56.123400-05:00',
'2013-01-02 09:12:56.123400-05:00',
'2013-01-03 09:12:56.123400-05:00'],
dtype='datetime64[ns, US/Eastern]', freq=None)
In [36]: dr.round('s')
Out[36]:
DatetimeIndex(['2013-01-01 09:12:56-05:00', '2013-01-02 09:12:56-05:00',
'2013-01-03 09:12:56-05:00'],
dtype='datetime64[ns, US/Eastern]', freq=None)
时间增量
In [37]: t = pd.timedelta_range('1 days 2 hr 13 min 45 us', periods=3, freq='d')
In [38]: t
Out[38]:
TimedeltaIndex(['1 days 02:13:00.000045', '2 days 02:13:00.000045',
'3 days 02:13:00.000045'],
dtype='timedelta64[ns]', freq='D')
In [39]: t.round('10min')
Out[39]: TimedeltaIndex(['1 days 02:10:00', '2 days 02:10:00', '3 days 02:10:00'], dtype='timedelta64[ns]', freq=None)
# Timedelta scalar
In [40]: t[0]
Out[40]: Timedelta('1 days 02:13:00.000045')
In [41]: t[0].round('2h')
Out[41]: Timedelta('1 days 02:00:00')
此外,.round()
、.floor()
和将通过的访问器.ceil()
可用。.dt
Series
In [42]: s = pd.Series(dr)
In [43]: s
Out[43]:
0 2013-01-01 09:12:56.123400-05:00
1 2013-01-02 09:12:56.123400-05:00
2 2013-01-03 09:12:56.123400-05:00
Length: 3, dtype: datetime64[ns, US/Eastern]
In [44]: s.dt.round('D')
Out[44]:
0 2013-01-01 00:00:00-05:00
1 2013-01-02 00:00:00-05:00
2 2013-01-03 00:00:00-05:00
Length: 3, dtype: datetime64[ns, US/Eastern]
FloatIndex 中整数的格式#
中的整数FloatIndex
(例如 1.)现在使用小数点和数字进行格式化0
,例如1.0
( GH 11713 ) 此更改不仅会影响控制台的显示,还会影响.to_csv
或等 IO 方法的输出.to_html
。
以前的行为:
In [2]: s = pd.Series([1, 2, 3], index=np.arange(3.))
In [3]: s
Out[3]:
0 1
1 2
2 3
dtype: int64
In [4]: s.index
Out[4]: Float64Index([0.0, 1.0, 2.0], dtype='float64')
In [5]: print(s.to_csv(path=None))
0,1
1,2
2,3
新行为:
In [45]: s = pd.Series([1, 2, 3], index=np.arange(3.))
In [46]: s
Out[46]:
0.0 1
1.0 2
2.0 3
Length: 3, dtype: int64
In [47]: s.index
Out[47]: Index([0.0, 1.0, 2.0], dtype='float64')
In [48]: print(s.to_csv(path_or_buf=None, header=False))
0.0,1
1.0,2
2.0,3
数据类型分配行为的更改#
当使用相同数据类型的新切片更新 DataFrame 的切片时,DataFrame 的 dtype 现在将保持不变。 (GH 10503)
以前的行为:
In [5]: df = pd.DataFrame({'a': [0, 1, 1],
'b': pd.Series([100, 200, 300], dtype='uint32')})
In [7]: df.dtypes
Out[7]:
a int64
b uint32
dtype: object
In [8]: ix = df['a'] == 1
In [9]: df.loc[ix, 'b'] = df.loc[ix, 'b']
In [11]: df.dtypes
Out[11]:
a int64
b int64
dtype: object
新行为:
In [49]: df = pd.DataFrame({'a': [0, 1, 1],
....: 'b': pd.Series([100, 200, 300], dtype='uint32')})
....:
In [50]: df.dtypes
Out[50]:
a int64
b uint32
Length: 2, dtype: object
In [51]: ix = df['a'] == 1
In [52]: df.loc[ix, 'b'] = df.loc[ix, 'b']
In [53]: df.dtypes
Out[53]:
a int64
b uint32
Length: 2, dtype: object
当 DataFrame 的整数切片部分更新为新的浮点切片(可能会向下转换为整数而不丢失精度)时,切片的 dtype 将设置为浮点而不是整数。
以前的行为:
In [4]: df = pd.DataFrame(np.array(range(1,10)).reshape(3,3),
columns=list('abc'),
index=[[4,4,8], [8,10,12]])
In [5]: df
Out[5]:
a b c
4 8 1 2 3
10 4 5 6
8 12 7 8 9
In [7]: df.ix[4, 'c'] = np.array([0., 1.])
In [8]: df
Out[8]:
a b c
4 8 1 2 0
10 4 5 1
8 12 7 8 9
新行为:
In [54]: df = pd.DataFrame(np.array(range(1,10)).reshape(3,3),
....: columns=list('abc'),
....: index=[[4,4,8], [8,10,12]])
....:
In [55]: df
Out[55]:
a b c
4 8 1 2 3
10 4 5 6
8 12 7 8 9
[3 rows x 3 columns]
In [56]: df.loc[4, 'c'] = np.array([0., 1.])
In [57]: df
Out[57]:
a b c
4 8 1 2 0
10 4 5 1
8 12 7 8 9
[3 rows x 3 columns]
方法 to_xarray #
在 pandas 的未来版本中,我们将弃用Panel
和其他 > 2 ndim 对象。为了提供连续性,所有NDFrame
对象都获得了.to_xarray()
转换为xarray
对象的方法,该方法具有类似于 pandas 的接口,适用于 > 2 ndim。 (GH 11972)
请参阅此处的 xarray 完整文档。
In [1]: p = Panel(np.arange(2*3*4).reshape(2,3,4))
In [2]: p.to_xarray()
Out[2]:
<xarray.DataArray (items: 2, major_axis: 3, minor_axis: 4)>
array([[[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]],
[[12, 13, 14, 15],
[16, 17, 18, 19],
[20, 21, 22, 23]]])
Coordinates:
* items (items) int64 0 1
* major_axis (major_axis) int64 0 1 2
* minor_axis (minor_axis) int64 0 1 2 3
乳胶表示#
DataFrame
获得了一种._repr_latex_()
方法,可以使用 nbconvert 在 ipython/jupyter 笔记本中转换为乳胶。 (GH 11778)
请注意,必须通过设置选项pd.display.latex.repr=True
(GH 12182)来激活它
例如,如果您有一个 jupyter 笔记本,计划使用 nbconvert 转换为 Latex,请将语句放在pd.display.latex.repr=True
第一个单元格中,以使包含的 DataFrame 输出也存储为 Latex。
选项display.latex.escape
和display.latex.longtable
也已添加到配置中并由该方法自动使用to_latex
。有关更多信息,请参阅可用选项文档。
pd.read_sas()
变化#
read_sas
已获得读取 SAS7BDAT 文件(包括压缩文件)的能力。这些文件可以完整读取,也可以增量读取。有关完整详细信息,请参阅此处。 (GH 4052)
其他增强功能#
处理 SAS xport 文件中截断的浮点数 ( GH 11713 )
添加了隐藏索引的选项
Series.to_string
(GH 11729)read_excel
现在支持格式的 s3 urls3://bucketname/filename
( GH 11447 )AWS_S3_HOST
从 s3 读取时添加对 env 变量的支持( GH 12198 )Panel.round()
现已实现一个简单版本( GH 11763)对于 Python 3.x,
round(DataFrame)
,round(Series)
,round(Panel)
可以工作 ( GH 11763 )sys.getsizeof(obj)
返回 pandas 对象的内存使用情况,包括它包含的值 ( GH 11597 )Series
获得is_unique
属性(GH 11946)DataFrame.quantile
现在Series.quantile
接受interpolation
关键字(GH 10174)。添加了
DataFrame.style.format
更灵活的单元格值格式(GH 11692)DataFrame.select_dtypes
现在允许np.float16
类型代码(GH 11990)pivot_table()
现在接受参数的大多数迭代values
(GH 12017)添加了 Google
BigQuery
服务帐户身份验证支持,可在远程服务器上进行身份验证。 (GH 11881,GH 12572)。欲了解更多详情,请参阅此处HDFStore
现在是可迭代的:相当于(GH 12221)。for k in store
for k in store.keys()
将缺少的方法/字段添加到
.dt
forPeriod
( GH 8848 )整个代码库已被
PEP
标准化(GH 12096)
向后不兼容的 API 更改#
前导空格已从
.to_string(index=False)
方法的输出中删除(GH 11833)该
out
参数已从该Series.round()
方法中删除。 (GH 11763)DataFrame.round()
在返回中保持非数字列不变,而不是引发。 (GH 11885)DataFrame.head(0)
并DataFrame.tail(0)
返回空帧,而不是self
. (GH 11937)Series.head(0)
并Series.tail(0)
返回空系列,而不是self
. (GH 11937)to_msgpack
并且read_msgpack
编码现在默认为'utf-8'
. (GH 12170).read_csv()
文本文件解析函数 ( ,.read_table()
, )的关键字参数顺序.read_fwf()
更改为对相关参数进行分组。 (GH 11555)NaTType.isoformat
现在返回字符串'NaT
以允许将结果传递给 的构造函数Timestamp
。 (GH 12300)
NaT 和 Timedelta 操作#
NaT
并Timedelta
扩展了算术运算,在适用的情况下将其扩展到Series
算术。为datetime64[ns]
or定义的操作现在也为( GH 11564timedelta64[ns]
)
定义。NaT
NaT
现在支持整数和浮点数的算术运算。
In [58]: pd.NaT * 1
Out[58]: NaT
In [59]: pd.NaT * 1.5
Out[59]: NaT
In [60]: pd.NaT / 2
Out[60]: NaT
In [61]: pd.NaT * np.nan
Out[61]: NaT
NaT
datetime64[ns]
使用和定义更多算术运算timedelta64[ns]
。
In [62]: pd.NaT / pd.NaT
Out[62]: nan
In [63]: pd.Timedelta('1s') / pd.NaT
Out[63]: nan
NaT
可以表示datetime64[ns]
null 或timedelta64[ns]
null。由于存在歧义,它被视为timedelta64[ns]
,这使得更多操作能够成功。
In [64]: pd.NaT + pd.NaT
Out[64]: NaT
# same as
In [65]: pd.Timedelta('1s') + pd.Timedelta('1s')
Out[65]: Timedelta('0 days 00:00:02')
相对于
In [3]: pd.Timestamp('19900315') + pd.Timestamp('19900315')
TypeError: unsupported operand type(s) for +: 'Timestamp' and 'Timestamp'
但是,当包装在Series
who 的dtype
isdatetime64[ns]
或 中时timedelta64[ns]
,该dtype
信息会受到尊重。
In [1]: pd.Series([pd.NaT], dtype='<M8[ns]') + pd.Series([pd.NaT], dtype='<M8[ns]')
TypeError: can only operate on a datetimes for subtraction,
but the operator [__add__] was passed
In [66]: pd.Series([pd.NaT], dtype='<m8[ns]') + pd.Series([pd.NaT], dtype='<m8[ns]')
Out[66]:
0 NaT
Length: 1, dtype: timedelta64[ns]
Timedelta
分工floats
现在可以工作了。
In [67]: pd.Timedelta('1s') / 2.0
Out[67]: Timedelta('0 days 00:00:00.500000')
Timedelta
由一个作品减goSeries
一个Timestamp
作品(GH 11925)
In [68]: ser = pd.Series(pd.timedelta_range('1 day', periods=3))
In [69]: ser
Out[69]:
0 1 days
1 2 days
2 3 days
Length: 3, dtype: timedelta64[ns]
In [70]: pd.Timestamp('2012-01-01') - ser
Out[70]:
0 2011-12-31
1 2011-12-30
2 2011-12-29
Length: 3, dtype: datetime64[ns]
NaT.isoformat()
现在返回'NaT'
。此更改允许
pd.Timestamp
从其 isoformat ( GH 12300 ) 中重新水化任何类似时间戳的对象。
msgpack 的更改#
msgpack
在 0.17.0 和 0.18.0 上进行了向前不兼容的写入格式更改;旧版本的 pandas 无法读取新版本打包的文件(GH 12129,GH 10527)
to_msgpack
0.17.0 中引入并在 0.18.0 中修复的错误read_msgpack
导致 Python 3 无法读取 Python 2 中打包的文件 ( GH 12142 )。下表描述了 msgpack 的向后和向前兼容性。
警告
挤满了 |
可以用以下方式解压 |
---|---|
0.17 之前/Python 2 |
任何 |
0.17 之前/Python 3 |
任何 |
0.17/Python 2 |
|
0.17/Python 3 |
>=0.18 / 任何 Python |
0.18 |
>= 0.18 |
0.18.0 向后兼容读取旧版本打包的文件,但 Python 2 中使用 0.17 打包的文件除外,在这种情况下只能在 Python 2 中解包。
.rank 的签名更改#
Series.rank
现在DataFrame.rank
有相同的签名(GH 11759)
以前的签名
In [3]: pd.Series([0,1]).rank(method='average', na_option='keep',
ascending=True, pct=False)
Out[3]:
0 1
1 2
dtype: float64
In [4]: pd.DataFrame([0,1]).rank(axis=0, numeric_only=None,
method='average', na_option='keep',
ascending=True, pct=False)
Out[4]:
0
0 1
1 2
新签名
In [71]: pd.Series([0,1]).rank(axis=0, method='average', numeric_only=False,
....: na_option='keep', ascending=True, pct=False)
....:
Out[71]:
0 1.0
1 2.0
Length: 2, dtype: float64
In [72]: pd.DataFrame([0,1]).rank(axis=0, method='average', numeric_only=False,
....: na_option='keep', ascending=True, pct=False)
....:
Out[72]:
0
0 1.0
1 2.0
[2 rows x 1 columns]
QuarterBegin 中 n=0 时的错误#
在以前的版本中,QuarterBegin 偏移量的行为根据参数n
为 0 时的日期而不一致。( GH 11406 )
锚定偏移量的一般语义n=0
是当日期是锚点时(例如,季度开始日期),不移动日期,否则前滚到下一个锚点。
In [73]: d = pd.Timestamp('2014-02-01')
In [74]: d
Out[74]: Timestamp('2014-02-01 00:00:00')
In [75]: d + pd.offsets.QuarterBegin(n=0, startingMonth=2)
Out[75]: Timestamp('2014-02-01 00:00:00')
In [76]: d + pd.offsets.QuarterBegin(n=0, startingMonth=1)
Out[76]: Timestamp('2014-04-01 00:00:00')
对于以前版本中的偏移,如果日期与季度开始日期在同一个月,则QuarterBegin
日期将
向后滚动。
In [3]: d = pd.Timestamp('2014-02-15')
In [4]: d + pd.offsets.QuarterBegin(n=0, startingMonth=2)
Out[4]: Timestamp('2014-02-01 00:00:00')
MonthBegin
此行为已在版本 0.18.0 中得到纠正,这与其他锚定偏移量(如和 )一致YearBegin
。
In [77]: d = pd.Timestamp('2014-02-15')
In [78]: d + pd.offsets.QuarterBegin(n=0, startingMonth=2)
Out[78]: Timestamp('2014-05-01 00:00:00')
重新采样 API #
就像上面窗口函数 API 中的更改一样,.resample(...)
正在更改为具有更像 groupby 的 API。 (GH 11732、GH 12702、GH 12202、GH 12332、GH 12334、GH 12348、GH 12448)。
In [79]: np.random.seed(1234)
In [80]: df = pd.DataFrame(np.random.rand(10,4),
....: columns=list('ABCD'),
....: index=pd.date_range('2010-01-01 09:00:00',
....: periods=10, freq='s'))
....:
In [81]: df
Out[81]:
A B C D
2010-01-01 09:00:00 0.191519 0.622109 0.437728 0.785359
2010-01-01 09:00:01 0.779976 0.272593 0.276464 0.801872
2010-01-01 09:00:02 0.958139 0.875933 0.357817 0.500995
2010-01-01 09:00:03 0.683463 0.712702 0.370251 0.561196
2010-01-01 09:00:04 0.503083 0.013768 0.772827 0.882641
2010-01-01 09:00:05 0.364886 0.615396 0.075381 0.368824
2010-01-01 09:00:06 0.933140 0.651378 0.397203 0.788730
2010-01-01 09:00:07 0.316836 0.568099 0.869127 0.436173
2010-01-01 09:00:08 0.802148 0.143767 0.704261 0.704581
2010-01-01 09:00:09 0.218792 0.924868 0.442141 0.909316
[10 rows x 4 columns]
以前的API:
您将编写一个立即评估的重采样操作。如果how
未提供参数,则默认为how='mean'
。
In [6]: df.resample('2s')
Out[6]:
A B C D
2010-01-01 09:00:00 0.485748 0.447351 0.357096 0.793615
2010-01-01 09:00:02 0.820801 0.794317 0.364034 0.531096
2010-01-01 09:00:04 0.433985 0.314582 0.424104 0.625733
2010-01-01 09:00:06 0.624988 0.609738 0.633165 0.612452
2010-01-01 09:00:08 0.510470 0.534317 0.573201 0.806949
您也可以how
直接指定
In [7]: df.resample('2s', how='sum')
Out[7]:
A B C D
2010-01-01 09:00:00 0.971495 0.894701 0.714192 1.587231
2010-01-01 09:00:02 1.641602 1.588635 0.728068 1.062191
2010-01-01 09:00:04 0.867969 0.629165 0.848208 1.251465
2010-01-01 09:00:06 1.249976 1.219477 1.266330 1.224904
2010-01-01 09:00:08 1.020940 1.068634 1.146402 1.613897
新的API:
现在,您可以编写.resample(..)
为 2 阶段操作,例如.groupby(...)
,它会生成Resampler
.
In [82]: r = df.resample('2s')
In [83]: r
Out[83]: <pandas.core.resample.DatetimeIndexResampler object at 0x7ff230e71c30>
下采样#
然后您可以使用该对象来执行操作。这些是下采样操作(从较高频率到较低频率)。
In [84]: r.mean()
Out[84]:
A B C D
2010-01-01 09:00:00 0.485748 0.447351 0.357096 0.793615
2010-01-01 09:00:02 0.820801 0.794317 0.364034 0.531096
2010-01-01 09:00:04 0.433985 0.314582 0.424104 0.625733
2010-01-01 09:00:06 0.624988 0.609738 0.633165 0.612452
2010-01-01 09:00:08 0.510470 0.534317 0.573201 0.806949
[5 rows x 4 columns]
In [85]: r.sum()
Out[85]:
A B C D
2010-01-01 09:00:00 0.971495 0.894701 0.714192 1.587231
2010-01-01 09:00:02 1.641602 1.588635 0.728068 1.062191
2010-01-01 09:00:04 0.867969 0.629165 0.848208 1.251465
2010-01-01 09:00:06 1.249976 1.219477 1.266330 1.224904
2010-01-01 09:00:08 1.020940 1.068634 1.146402 1.613897
[5 rows x 4 columns]
此外,重新采样现在支持getitem
对特定列执行重新采样的操作。
In [86]: r[['A','C']].mean()
Out[86]:
A C
2010-01-01 09:00:00 0.485748 0.357096
2010-01-01 09:00:02 0.820801 0.364034
2010-01-01 09:00:04 0.433985 0.424104
2010-01-01 09:00:06 0.624988 0.633165
2010-01-01 09:00:08 0.510470 0.573201
[5 rows x 2 columns]
和.aggregate
类型操作。
In [87]: r.agg({'A' : 'mean', 'B' : 'sum'})
Out[87]:
A B
2010-01-01 09:00:00 0.485748 0.894701
2010-01-01 09:00:02 0.820801 1.588635
2010-01-01 09:00:04 0.433985 0.629165
2010-01-01 09:00:06 0.624988 1.219477
2010-01-01 09:00:08 0.510470 1.068634
[5 rows x 2 columns]
当然,这些访问器可以组合起来
In [88]: r[['A','B']].agg(['mean','sum'])
Out[88]:
A B
mean sum mean sum
2010-01-01 09:00:00 0.485748 0.971495 0.447351 0.894701
2010-01-01 09:00:02 0.820801 1.641602 0.794317 1.588635
2010-01-01 09:00:04 0.433985 0.867969 0.314582 0.629165
2010-01-01 09:00:06 0.624988 1.249976 0.609738 1.219477
2010-01-01 09:00:08 0.510470 1.020940 0.534317 1.068634
[5 rows x 4 columns]
上采样#
上采样操作将您从较低频率带到较高频率。这些现在是通过Resampler
带有backfill()
、
ffill()
、fillna()
和asfreq()
方法的对象来执行的。
In [89]: s = pd.Series(np.arange(5, dtype='int64'),
index=pd.date_range('2010-01-01', periods=5, freq='Q'))
In [90]: s
Out[90]:
2010-03-31 0
2010-06-30 1
2010-09-30 2
2010-12-31 3
2011-03-31 4
Freq: Q-DEC, Length: 5, dtype: int64
之前
In [6]: s.resample('M', fill_method='ffill')
Out[6]:
2010-03-31 0
2010-04-30 0
2010-05-31 0
2010-06-30 1
2010-07-31 1
2010-08-31 1
2010-09-30 2
2010-10-31 2
2010-11-30 2
2010-12-31 3
2011-01-31 3
2011-02-28 3
2011-03-31 4
Freq: M, dtype: int64
新的API
In [91]: s.resample('M').ffill()
Out[91]:
2010-03-31 0
2010-04-30 0
2010-05-31 0
2010-06-30 1
2010-07-31 1
2010-08-31 1
2010-09-30 2
2010-10-31 2
2010-11-30 2
2010-12-31 3
2011-01-31 3
2011-02-28 3
2011-03-31 4
Freq: M, Length: 13, dtype: int64
笔记
在新的 API 中,您可以下采样或上采样。先前的实现将允许您传递聚合器函数(例如mean
),即使您正在进行上采样,这也会造成一些混乱。
以前的 API 可以使用,但已弃用#
警告
这个用于重新采样的新 API 包括对 0.18.0 之前的 API 的一些内部更改,以便在大多数情况下处理弃用警告,因为重新采样操作返回延迟对象。我们可以拦截操作并执行(0.18.0 之前)API 所做的操作(带有警告)。这是一个典型的用例:
In [4]: r = df.resample('2s')
In [6]: r*10
pandas/tseries/resample.py:80: FutureWarning: .resample() is now a deferred operation
use .resample(...).mean() instead of .resample(...)
Out[6]:
A B C D
2010-01-01 09:00:00 4.857476 4.473507 3.570960 7.936154
2010-01-01 09:00:02 8.208011 7.943173 3.640340 5.310957
2010-01-01 09:00:04 4.339846 3.145823 4.241039 6.257326
2010-01-01 09:00:06 6.249881 6.097384 6.331650 6.124518
2010-01-01 09:00:08 5.104699 5.343172 5.732009 8.069486
但是,直接对 a 进行获取和赋值操作Resampler
将引发 a ValueError
:
In [7]: r.iloc[0] = 5
ValueError: .resample() is now a deferred operation
use .resample(...).mean() instead of .resample(...)
存在一种情况,新的 API 无法执行使用原始代码时的所有操作。此代码打算每 2 秒重新采样一次,采用mean
AND,然后采用min
这些结果。
In [4]: df.resample('2s').min()
Out[4]:
A 0.433985
B 0.314582
C 0.357096
D 0.531096
dtype: float64
新的 API 将:
In [89]: df.resample('2s').min()
Out[89]:
A B C D
2010-01-01 09:00:00 0.191519 0.272593 0.276464 0.785359
2010-01-01 09:00:02 0.683463 0.712702 0.357817 0.500995
2010-01-01 09:00:04 0.364886 0.013768 0.075381 0.368824
2010-01-01 09:00:06 0.316836 0.568099 0.397203 0.436173
2010-01-01 09:00:08 0.218792 0.143767 0.442141 0.704581
[5 rows x 4 columns]
好消息是新 API 和旧 API 的返回维度会有所不同,因此这应该会引发异常。
复制原始操作
In [90]: df.resample('2s').mean().min()
Out[90]:
A 0.433985
B 0.314582
C 0.357096
D 0.531096
Length: 4, dtype: float64
对评估的更改#
在以前的版本中,eval
表达式中的新列分配会导致对DataFrame
. (GH 9297、GH 8664、GH 10486)
In [91]: df = pd.DataFrame({'a': np.linspace(0, 10, 5), 'b': range(5)})
In [92]: df
Out[92]:
a b
0 0.0 0
1 2.5 1
2 5.0 2
3 7.5 3
4 10.0 4
[5 rows x 2 columns]
In [12]: df.eval('c = a + b')
FutureWarning: eval expressions containing an assignment currentlydefault to operating inplace.
This will change in a future version of pandas, use inplace=True to avoid this warning.
In [13]: df
Out[13]:
a b c
0 0.0 0 0.0
1 2.5 1 3.5
2 5.0 2 7.0
3 7.5 3 10.5
4 10.0 4 14.0
在 0.18.0 版本中,inplace
添加了一个新关键字来选择是应就地完成分配还是返回副本。
In [93]: df
Out[93]:
a b c
0 0.0 0 0.0
1 2.5 1 3.5
2 5.0 2 7.0
3 7.5 3 10.5
4 10.0 4 14.0
[5 rows x 3 columns]
In [94]: df.eval('d = c - b', inplace=False)
Out[94]:
a b c d
0 0.0 0 0.0 0.0
1 2.5 1 3.5 2.5
2 5.0 2 7.0 5.0
3 7.5 3 10.5 7.5
4 10.0 4 14.0 10.0
[5 rows x 4 columns]
In [95]: df
Out[95]:
a b c
0 0.0 0 0.0
1 2.5 1 3.5
2 5.0 2 7.0
3 7.5 3 10.5
4 10.0 4 14.0
[5 rows x 3 columns]
In [96]: df.eval('d = c - b', inplace=True)
In [97]: df
Out[97]:
a b c d
0 0.0 0 0.0 0.0
1 2.5 1 3.5 2.5
2 5.0 2 7.0 5.0
3 7.5 3 10.5 7.5
4 10.0 4 14.0 10.0
[5 rows x 4 columns]
警告
为了向后兼容,如果未指定,则inplace
默认为。True
这将在 pandas 的未来版本中改变。如果您的代码依赖于就地分配,您应该更新以显式设置inplace=True
inplace
该方法还添加了关键字参数query
。
In [98]: df.query('a > 5')
Out[98]:
a b c d
3 7.5 3 10.5 7.5
4 10.0 4 14.0 10.0
[2 rows x 4 columns]
In [99]: df.query('a > 5', inplace=True)
In [100]: df
Out[100]:
a b c d
3 7.5 3 10.5 7.5
4 10.0 4 14.0 10.0
[2 rows x 4 columns]
警告
注意, ainplace
中的默认值为,与之前版本一致。query
False
eval
还进行了更新,允许使用多行表达式进行多项赋值。这些表达式将按顺序一次计算一个。只有赋值对多行表达式有效。
In [101]: df
Out[101]:
a b c d
3 7.5 3 10.5 7.5
4 10.0 4 14.0 10.0
[2 rows x 4 columns]
In [102]: df.eval("""
.....: e = d + a
.....: f = e - 22
.....: g = f / 2.0""", inplace=True)
.....:
In [103]: df
Out[103]:
a b c d e f g
3 7.5 3 10.5 7.5 15.0 -7.0 -3.5
4 10.0 4 14.0 10.0 20.0 -2.0 -1.0
[2 rows x 7 columns]
其他 API 更改#
DataFrame.between_time
现在Series.between_time
只解析一组固定的时间字符串。不再支持日期字符串的解析并引发ValueError
. (GH 11818)In [107]: s = pd.Series(range(10), pd.date_range('2015-01-01', freq='H', periods=10)) In [108]: s.between_time("7:00am", "9:00am") Out[108]: 2015-01-01 07:00:00 7 2015-01-01 08:00:00 8 2015-01-01 09:00:00 9 Freq: H, Length: 3, dtype: int64
现在这个数字将会上升。
In [2]: s.between_time('20150101 07:00:00','20150101 09:00:00') ValueError: Cannot convert arg ['20150101 07:00:00'] to a time.
.memory_usage()
现在包括索引中的值,就像.info()
( GH 11597 )中的 memory_usage 一样DataFrame.to_latex()
现在支持 Python 2 中的非 ascii 编码(例如utf-8
),参数为encoding
( GH 7061 )pandas.merge()
并DataFrame.merge()
在尝试与非类型DataFrame
或子类的对象合并时显示特定错误消息(GH 12081)DataFrame.unstack
现在,当 unstack 导致结果中缺失值时,Series.unstack
采用关键字允许直接替换缺失值。作为一个额外的好处,指定将保留原始堆栈数据的数据类型。 (GH 9746)fill_value
DataFrame
fill_value
作为窗口函数和重采样的新 API 的一部分,聚合函数已得到澄清,针对无效聚合提出了更多信息丰富的错误消息。 (GH 9052)。groupby中提供了完整的示例集。
如果传入非 numpy 兼容的参数(GH 12301),则对象的统计函数
NDFrame
(例如)现在将引发sum(), mean(), min()
**kwargs
.to_latex
并.to_html
获得decimal
像这样的参数.to_csv
;默认为'.'
(GH 12031)DataFrame
构造带有空数据但带有索引的a 时更有用的错误消息( GH 8020).describe()
现在将正确处理 bool dtype 作为分类 ( GH 6625 ).transform
用户定义的输入无效的更有用的错误消息( GH 10165)指数加权函数现在允许直接指定 alpha ( GH 10789 ) 并
ValueError
在参数违反时引发( GH 12492 )0 < alpha <= 1
弃用#
函数
pd.rolling_*
、pd.expanding_*
和pd.ewm*
已弃用并由相应的方法调用取代。请注意,新建议的语法包括所有参数(即使是默认参数)( GH 11603 )In [1]: s = pd.Series(range(3)) In [2]: pd.rolling_mean(s,window=2,min_periods=1) FutureWarning: pd.rolling_mean is deprecated for Series and will be removed in a future version, replace with Series.rolling(min_periods=1,window=2,center=False).mean() Out[2]: 0 0.0 1 0.5 2 1.5 dtype: float64 In [3]: pd.rolling_cov(s, s, window=2) FutureWarning: pd.rolling_cov is deprecated for Series and will be removed in a future version, replace with Series.rolling(window=2).cov(other=<Series>) Out[3]: 0 NaN 1 0.5 2 0.5 dtype: float64
、和(新)函数的
freq
和参数已弃用,并将在未来版本中删除。您可以在创建窗口函数之前简单地对输入进行重新采样。 (GH 11603)。how
.rolling
.expanding
.ewm
例如,
s.rolling(window=5,freq='D').max()
可以使用 ,而不是获取滚动 5 天窗口的最大值,s.resample('D').mean().rolling(window=5).max()
它首先将数据重新采样为每日数据,然后提供滚动 5 天窗口。pd.tseries.frequencies.get_offset_name
函数已被弃用。使用 offset 的.freqstr
属性作为替代(GH 11192)pandas.stats.fama_macbeth
例程已弃用,并将在未来版本中删除(GH 6077)pandas.stats.ols
,pandas.stats.plm
并且pandas.stats.var
例程已弃用并将在未来版本中删除(GH 6077)在 中使用长期不推荐使用的语法显示 a
FutureWarning
而不是 a on ,其中该子句不是类似字符串的 ( GH 12027 )DeprecationWarning
HDFStore.select
where
该
pandas.options.display.mpl_style
配置已被弃用,并将在 pandas 的未来版本中删除。 matplotlib 的样式表(GH 11783)可以更好地处理此功能。
删除已弃用的浮点索引器#
在GH 4892中,不推荐使用非浮点数进行索引Float64Index
(在版本 0.14.0 中)。在 0.18.0 中,此弃用警告已被删除,现在将引发TypeError
. (GH 12165,GH 12333)
In [104]: s = pd.Series([1, 2, 3], index=[4, 5, 6])
In [105]: s
Out[105]:
4 1
5 2
6 3
Length: 3, dtype: int64
In [106]: s2 = pd.Series([1, 2, 3], index=list('abc'))
In [107]: s2
Out[107]:
a 1
b 2
c 3
Length: 3, dtype: int64
以前的行为:
# this is label indexing
In [2]: s[5.0]
FutureWarning: scalar indexers for index type Int64Index should be integers and not floating point
Out[2]: 2
# this is positional indexing
In [3]: s.iloc[1.0]
FutureWarning: scalar indexers for index type Int64Index should be integers and not floating point
Out[3]: 2
# this is label indexing
In [4]: s.loc[5.0]
FutureWarning: scalar indexers for index type Int64Index should be integers and not floating point
Out[4]: 2
# .ix would coerce 1.0 to the positional 1, and index
In [5]: s2.ix[1.0] = 10
FutureWarning: scalar indexers for index type Index should be integers and not floating point
In [6]: s2
Out[6]:
a 1
b 10
c 3
dtype: int64
新行为:
对于 iloc,通过浮点标量获取和设置总是会引发。
In [3]: s.iloc[2.0]
TypeError: cannot do label indexing on <class 'pandas.indexes.numeric.Int64Index'> with these indexers [2.0] of <type 'float'>
其他索引器将强制获取和设置类似的整数。已FutureWarning
被删除为.loc
、.ix
和[]
。
In [108]: s[5.0]
Out[108]: 2
In [109]: s.loc[5.0]
Out[109]: 2
和设置
In [110]: s_copy = s.copy()
In [111]: s_copy[5.0] = 10
In [112]: s_copy
Out[112]:
4 1
5 10
6 3
Length: 3, dtype: int64
In [113]: s_copy = s.copy()
In [114]: s_copy.loc[5.0] = 10
In [115]: s_copy
Out[115]:
4 1
5 10
6 3
Length: 3, dtype: int64
使用浮动索引器进行位置设置.ix
会将这个值添加到索引中,而不是之前按位置设置值。
In [3]: s2.ix[1.0] = 10
In [4]: s2
Out[4]:
a 1
b 2
c 3
1.0 10
dtype: int64
切片还会将类似整数的浮点数强制转换为非Float64Index
.
In [116]: s.loc[5.0:6]
Out[116]:
5 2
6 3
Length: 2, dtype: int64
请注意,对于不可强制转换为整数的浮点数,基于标签的边界将被排除
In [117]: s.loc[5.1:6]
Out[117]:
6 3
Length: 1, dtype: int64
a 上的浮点索引Float64Index
不变。
In [118]: s = pd.Series([1, 2, 3], index=np.arange(3.))
In [119]: s[1.0]
Out[119]: 2
In [120]: s[1.0:2.5]
Out[120]:
1.0 2
2.0 3
Length: 2, dtype: int64
删除先前版本的弃用/更改#
删除
rolling_corr_pairwise
以支持.rolling().corr(pairwise=True)
( GH 4950 )删除
expanding_corr_pairwise
以支持.expanding().corr(pairwise=True)
( GH 4950 )拆除
DataMatrix
模块。无论如何,这都没有导入到 pandas 命名空间中(GH 12111)删除
cols
关键字以支持subset
inDataFrame.duplicated()
andDataFrame.drop_duplicates()
( GH 6680 )删除命名空间中的
read_frame
andframe_query
( 的别名pd.read_sql
) 和write_frame
( 的别名to_sql
) 函数pd.io.sql
,自 0.14.0 ( GH 6292 ) 起已弃用。order
从.factorize()
( GH 6930 )中删除关键字
性能改进#
Bug修复#
GroupBy.size
当数据框为空时出现错误。 (GH 11699)Period.end_time
请求多个时间段时出现错误( GH 11738).clip
使用 tz 感知的日期时间进行回归( GH 11838 )将嵌套字典传递给的一致性错误
.groupby(...).agg(...)
(GH 9052)在构造函数中接受 unicode
Timedelta
( GH 11995 )增量读取时值标签读取错误
StataReader
(GH 12014)DateOffset
当n
参数为0
(GH 11370)时矢量化中的错误兼容 numpy 1.11 wrt
NaT
比较更改(GH 12049)read_csv
从线程中读取时出现错误StringIO
(GH 11790)在分解 & 时不将其视为
NaT
datetimelikes 中的缺失值的错误Categoricals
( GH 12077 )当 a 的值
Series
可识别 tz 时,getitem 中存在错误(GH 12089)Series.str.get_dummies
当变量之一是“名称”时出现错误( GH 12180)pd.concat
连接 tz 感知的 NaT 系列时出现错误。 (GH 11693,GH 11755,GH 12217)pd.read_stata
版本 <= 108 个文件中的错误( GH 12232 )当索引为 a且包含非零纳秒部分时
Series.resample
使用频率时出现错误( GH 12037 )Nano
DatetimeIndex
.nunique
使用稀疏索引重新采样时出现错误( GH 12352)删除了一些编译器警告(GH 12471)
解决
boto
python 3.5 中的兼容性问题(GH 11915)NaT
从时区减goTimestamp
或与时区相减时出现错误DatetimeIndex
(GH 11718)减go
Series
单个 tz 感知的错误Timestamp
(GH 12290)在 PY2 中使用兼容迭代器来支持
.next()
(GH 12299)负值
Timedelta.round
错误(GH 11690)错误
.loc
可能CategoricalIndex
会导致正常Index
(GH 11586)DataFrame.info
存在重复的列名时出现错误( GH 11761).copy
日期时间 tz 感知对象的错误( GH 11794)错误
Series.apply
以及未装箱的Series.map
位置( GH 11349)timedelta64
Bug in
DataFrame.set_index()
with tz-awareSeries
( GH 12358 )DataFrame
子类中的错误AttributeError
没有传播(GH 11808)tz 感知数据上的 bug groupby,其中选择未返回
Timestamp
(GH 11616)错误
pd.read_clipboard
和pd.to_clipboard
功能不支持 Unicode;包含升级pyperclip
至 v1.5.15 ( GH 9263 )DataFrame.query
包含作业时出现错误( GH 8664)如果解包的列具有对象列,则
from_msgpack
其中的错误会失败。 (GH 11880)__contains__()
DataFrame
DataFrame
使用( GH 12169 )修复
.resample
分类数据TimedeltaIndex
DataFrame
将标量日期时间广播到(GH 11682)时时区信息丢失的错误从混合 tz 强制到 UTC 的
Index
创建中出现错误( GH 11488)Timestamp
to_numeric
如果输入超过一维则不会引发错误( GH 11776)解析非零分钟的时区偏移字符串时出现错误(GH 11708)
df.plot
在 matplotlib 1.5+ 下对条形图使用不正确颜色的错误( GH 11614)groupby
plot
使用关键字参数时方法中的错误( GH 11805)。设置时出现错误
DataFrame.duplicated
并drop_duplicates
导致虚假匹配keep=False
(GH 11864).loc
具有重复键的结果中的错误可能具有Index
不正确的数据类型(GH 11497)pd.rolling_median
即使有足够的内存,内存分配也失败的错误( GH 11696)带有
DataFrame.style
虚假零的错误(GH 12134)DataFrame.style
整数列不从 0 开始的错误( GH 12125 ).style.bar
使用特定浏览器可能无法正确呈现的错误( GH 11678)Timedelta
与 anumpy.array
的丰富比较中的错误Timedelta
导致了无限递归(GH 11835)DataFrame.round
删除列索引名称时出现错误( GH 11986)df.replace
替换混合数据类型中的值时出现错误Dataframe
(GH 11698)当未提供新名称时,错误
Index
会阻止复制传递的名称( GH 11193)Index
read_excel
当存在空表时无法读取任何非空表的错误并且sheetname=None
(GH 11711)提供关键字和时
read_excel
未能引发错误的错误( GH 11544)NotImplemented
parse_dates
date_parser
read_sql
连接pymysql
无法返回分块数据的错误( GH 11522).to_csv
忽略浮点索引的格式参数decimal
,na_rep
的错误float_format
( GH 11553 )错误
Int64Index
并Float64Index
阻止使用模运算符(GH 9244)MultiIndex.drop
未进行词法排序的多重索引的错误( GH 12078)DataFrame
屏蔽空时出现错误DataFrame
(GH 11859)当列数与提供的系列数不匹配时
.plot
可能修改输入的错误( GH 12039)。colors
Series.plot
当索引具有频率时失败的错误CustomBusinessDay
(GH 7222)。.to_sql
使用 sqlite 回退的值的错误datetime.time
(GH 8341)当(GH 12157)
read_excel
时无法读取一列数据的错误squeeze=True
如果数据框中只有一行,则不会为错误的列引发
.groupby
错误(GH 11741)KeyError
在空数据上指定的 dtype会
.read_csv
产生错误(GH 12048).read_csv
像这样的字符串'2E'
被视为有效浮点数的错误( GH 12237)使用调试符号构建pandas时出现错误(GH 12123)
删除了
millisecond
的属性DatetimeIndex
。这总是会引发一个ValueError
(GH 12019)。Series
具有只读数据的构造函数中的错误( GH 11502)已删除
pandas._testing.choice()
。应使用np.random.choice()
, 代替。 (GH 12386)setitem 索引器中的错误
.loc
阻止使用 TZ 感知的 DatetimeIndex ( GH 12050 )索引中的错误
.style
和多索引未出现(GH 11655)错误
to_msgpack
并且from_msgpack
未正确序列化或反序列化NaT
(GH 12307)。由于高度相似的值的舍入误差
.skew
而导致错误( GH 11974).kurt
Timestamp
如果 HHMMSS 未用“:”分隔,构造函数中会出现微秒分辨率丢失的错误( GH 10041)如果读取失败,src->buffer中的错误
buffer_rd_bytes
可能会被多次释放,从而导致段错误(GH 12098)crosstab
具有非重叠索引的参数将返回KeyError
( GH 10291 )的错误对于不是 numpy dtype 的
DataFrame.apply
情况,没有阻止减少的错误( GH 12244)dtype
使用标量值初始化分类系列时出现错误。 (GH 12336)
DatetimeIndex
通过utc=True
在.to_datetime
( GH 11934 )中设置指定 UTC 时出现错误增加 CSV 读取器缓冲区大小时出现的错误
read_csv
( GH 12494 )DataFrame
设置具有重复列名的 a 的列时出现错误( GH 12344)
贡献者#
共有 101 人为此版本贡献了补丁。名字带有“+”的人首次贡献了补丁。
射频+
亚历克斯·阿列克谢耶夫 +
安德鲁·麦克弗森 +
安德鲁·罗森菲尔德
安迪·海登
安东尼奥·帕特尼奥
安东·西波斯
本+
本·诺斯 +
布兰杨+
克里斯
克里斯·卡鲁克斯 +
克里斯托弗·艾科克 +
克里斯托弗·斯坎林 +
科迪+
大王+
丹尼尔·格雷迪 +
多罗日科·安东 +
欧文博士 +
埃里克·M·布雷 +
埃文·赖特
弗朗西斯·T·奥多诺万 +
弗兰克·克利里 +
詹卢卡·罗西
格雷厄姆·杰弗里斯 +
纪尧姆·霍雷尔
亨利·哈蒙德 +
艾萨克·施瓦巴赫 +
让·马蒂厄·德舍内
杰夫·雷巴克
乔·杰夫尼克 +
约翰·弗里曼 +
约翰·弗雷姆林 +
乔纳斯·霍尔施 +
乔里斯·范登博什
乔里斯·万克沙弗
贾斯汀·莱彻
林毅夫 +
陈嘉禾
张克明 +
克比谢登
凯尔+
马可·法鲁贾 +
梅森·加洛 +
马特·瑞克 +
马修·卢里 +
马克西米利安·鲁斯
玛雅克·阿萨纳 +
莫尔塔达·梅哈尔
穆萨·泰菲 +
纳弗里特·吉尔 +
尼古拉斯·博诺特
保罗·莱纳斯 +
菲利普·古拉 +
彼得罗·巴蒂斯顿
拉胡尔HP +
兰迪·卡内维尔
里诺克·约翰逊
里什普里 +
尚民公园 +
斯科特·拉斯利
塞雷格13 +
王香农 +
船长西博尔德
蒂埃里·莫伊桑
托马斯·卡斯威尔
托比·迪伦·霍金 +
汤姆·奥格斯普格
特拉维斯+
特伦特·豪克
燕尾服1
瓦伦
韦斯·麦金尼
威尔·汤普森+
约阿夫·拉姆
林永康 +
吉树·巴斯克斯·巴埃萨
金英中 +
金英根
尤瓦尔·兰格 +
亚历克斯·阿古诺夫 +
贝赫扎德·努里
轰鸣+
布莱恩·潘塔诺 +
铬+
丹尼尔+
dgram0 +
格菲扬+
hack-c +
h对比度 +
jfoo +
考斯图夫·德奥拉尔 +
呜呜呜
拉纳拉格+
罗格
scls19fr
密封件 +
辛赫克斯
斯里布+
调查媒体.ca +
两雷克+