1.2.0 版本的新功能 (2020 年 12 月 26 日)#
这是 pandas 1.2.0 版本中的变化。请参阅 发布说明 获取完整的更新日志,包括 pandas 的其他版本。
警告
用于写入旧式 .xls
excel 文件的 xlwt 包已不再维护。现在 xlrd 包仅用于读取旧式 .xls
文件。
之前,read_excel()
的默认参数 engine=None
在许多情况下会导致使用 xlrd
引擎,包括新的 Excel 2007+ (.xlsx
) 文件。如果安装了 openpyxl,现在许多此类情况将默认使用 openpyxl
引擎。有关更多详细信息,请参阅 read_excel()
文档。
因此,强烈建议安装 openpyxl
来读取 Excel 2007+ (.xlsx
) 文件。请勿在使用 xlrd
读取 .xlsx
文件时报告问题。这已不再受支持,请改用 openpyxl
。
尝试使用 xlwt
引擎将引发 FutureWarning
,除非将选项 io.excel.xls.writer
设置为 "xlwt"
。虽然此选项现已弃用并也将引发 FutureWarning
,但可以全局设置并抑制警告。建议用户改用 openpyxl
引擎写入 .xlsx
文件。
改进#
可选地禁止重复标签#
现在创建 Series
和 DataFrame
时可以使用 allows_duplicate_labels=False
标志来控制索引或列是否包含重复标签(GH 28394)。这可用于防止意外引入重复标签,从而影响下游操作。
默认情况下,仍然允许重复项。
In [1]: pd.Series([1, 2], index=['a', 'a'])
Out[1]:
a 1
a 2
Length: 2, dtype: int64
In [2]: pd.Series([1, 2], index=['a', 'a']).set_flags(allows_duplicate_labels=False)
...
DuplicateLabelError: Index has duplicates.
positions
label
a [0, 1]
pandas 将通过许多操作传播 allows_duplicate_labels
属性。
In [3]: a = (
...: pd.Series([1, 2], index=['a', 'b'])
...: .set_flags(allows_duplicate_labels=False)
...: )
In [4]: a
Out[4]:
a 1
b 2
Length: 2, dtype: int64
# An operation introducing duplicates
In [5]: a.reindex(['a', 'b', 'a'])
...
DuplicateLabelError: Index has duplicates.
positions
label
a [0, 2]
[1 rows x 1 columns]
警告
这是一个实验性功能。目前,许多方法未能传播 allows_duplicate_labels
值。在未来版本中,预计每个接受或返回一个或多个 DataFrame 或 Series 对象的方法都将传播 allows_duplicate_labels
。
有关更多信息,请参阅 重复标签。
allows_duplicate_labels
标志存储在新的 DataFrame.flags
属性中。这存储应用于 pandas 对象的全局属性。这与 DataFrame.attrs
不同,后者存储应用于数据集的信息。
向 fsspec 后端传递参数#
许多读/写函数新增了可选参数 storage_options
,用于向存储后端传递参数字典。例如,这允许向 S3 和 GCS 存储传递凭据。哪些参数可以传递给哪些后端的详细信息可在各个存储后端的文档中找到(来自 fsspec 文档的内置实现详细信息以及外部实现链接)。请参阅章节 读/写远程文件。
GH 35655 增加了 fsspec 支持(包括 storage_options
),用于读取 excel 文件。
to_csv
支持二进制文件句柄#
to_csv()
支持二进制模式下的文件句柄(GH 19827 和 GH 35058),并支持 encoding
(GH 13068 和 GH 23854)和 compression
(GH 22555)。如果 pandas 无法自动检测文件句柄是以二进制模式还是文本模式打开,则需要提供 mode="wb"
。
例如
In [1]: import io
In [2]: data = pd.DataFrame([0, 1, 2])
In [3]: buffer = io.BytesIO()
In [4]: data.to_csv(buffer, encoding="utf-8", compression="gzip")
to_latex
支持短标题和表格位置#
DataFrame.to_latex()
现在允许指定浮动表格位置(GH 35281)和短标题(GH 36267)。
新增了关键字参数 position
来设置位置。
In [5]: data = pd.DataFrame({'a': [1, 2], 'b': [3, 4]})
In [6]: table = data.to_latex(position='ht')
In [7]: print(table)
\begin{table}[ht]
\begin{tabular}{lrr}
\toprule
& a & b \\
\midrule
0 & 1 & 3 \\
1 & 2 & 4 \\
\bottomrule
\end{tabular}
\end{table}
关键字参数 caption
的用法已扩展。除了接受单个字符串参数外,还可以选择提供一个元组 (full_caption, short_caption)
来添加短标题宏。
In [8]: data = pd.DataFrame({'a': [1, 2], 'b': [3, 4]})
In [9]: table = data.to_latex(caption=('the full long caption', 'short caption'))
In [10]: print(table)
\begin{table}
\caption[short caption]{the full long caption}
\begin{tabular}{lrr}
\toprule
& a & b \\
\midrule
0 & 1 & 3 \\
1 & 2 & 4 \\
\bottomrule
\end{tabular}
\end{table}
read_csv
和 read_table
默认浮点精度更改#
对于 C 解析引擎,read_csv()
和 read_table()
方法之前默认使用一个解析器,该解析器在处理浮点数的最后一个位精度时可能会略有不准确。选项 floating_precision="high"
一直可用以避免此问题。从本版本开始,默认改为使用更精确的解析器,即将 floating_precision=None
对应于高精度解析器,而新增选项 floating_precision="legacy"
用于使用旧版解析器。默认改用更高精度解析器应该不会影响性能。(GH 17154)
浮点数据的实验性可空数据类型#
我们添加了 Float32Dtype
/ Float64Dtype
和 FloatingArray
。这些是专用于浮点数据的扩展数据类型,可以持有 pd.NA
缺失值指示符(GH 32265, GH 34307)。
虽然默认的浮点数据类型已经支持使用 np.nan
表示缺失值,但这些新的数据类型使用 pd.NA
(及其相应的行为)作为缺失值指示符,与已有的可空整数和布尔数据类型一致。
np.nan
和 pd.NA
行为不同的一个例子是比较操作
# the default NumPy float64 dtype
In [11]: s1 = pd.Series([1.5, None])
In [12]: s1
Out[12]:
0 1.5
1 NaN
Length: 2, dtype: float64
In [13]: s1 > 1
Out[13]:
0 True
1 False
Length: 2, dtype: bool
# the new nullable float64 dtype
In [14]: s2 = pd.Series([1.5, None], dtype="Float64")
In [15]: s2
Out[15]:
0 1.5
1 <NA>
Length: 2, dtype: Float64
In [16]: s2 > 1
Out[16]:
0 True
1 <NA>
Length: 2, dtype: boolean
有关使用 pd.NA
缺失值指示符时的行为详情,请参阅文档中的 NA 语义 部分。
如上所示,可以使用“Float64”或“Float32”字符串(大写以区别于默认的“float64”数据类型)指定 dtype。或者,您也可以使用 dtype 对象
In [17]: pd.Series([1.5, None], dtype=pd.Float32Dtype())
Out[17]:
0 1.5
1 <NA>
Length: 2, dtype: Float32
现有整数或布尔可空数据类型进行操作,如果结果是浮点类型,现在也将使用可空浮点数据类型(GH 38178)。
警告
实验性:新的浮点数据类型目前处于实验阶段,其行为或 API 可能会在没有警告的情况下发生变化。特别是关于 NaN(与 NA 缺失值不同)的行为可能会有所变动。
聚合时保留索引/列名称#
使用 concat()
或 DataFrame
构造函数进行聚合时,pandas 现在将尽可能尝试保留索引和列名称(GH 35847)。在所有输入共享一个共同名称的情况下,此名称将分配给结果。当输入名称不完全一致时,结果将没有名称。下面是保留索引名称的示例
In [18]: idx = pd.Index(range(5), name='abc')
In [19]: ser = pd.Series(range(5, 10), index=idx)
In [20]: pd.concat({'x': ser[1:], 'y': ser[:-1]}, axis=1)
Out[20]:
x y
abc
1 6.0 6.0
2 7.0 7.0
3 8.0 8.0
4 9.0 NaN
0 NaN 5.0
[5 rows x 2 columns]
MultiIndex
也是如此,但逻辑是逐级单独应用的。
GroupBy 直接支持 EWM 操作#
DataFrameGroupBy
现在直接支持指数加权窗口操作(GH 16037)。
In [21]: df = pd.DataFrame({'A': ['a', 'b', 'a', 'b'], 'B': range(4)})
In [22]: df
Out[22]:
A B
0 a 0
1 b 1
2 a 2
3 b 3
[4 rows x 2 columns]
In [23]: df.groupby('A').ewm(com=1.0).mean()
Out[23]:
B
A
a 0 0.000000
2 1.333333
b 1 1.000000
3 2.333333
[4 rows x 1 columns]
此外,mean
支持通过 Numba 执行,并带有 engine
和 engine_kwargs
参数。必须将 Numba 作为可选依赖项安装才能使用此功能。
其他改进#
为
Timestamp
、DatetimeIndex
、Period
、PeriodIndex
添加了day_of_week
属性(兼容性别名dayofweek
)(GH 9605)为
Timestamp
、DatetimeIndex
、Period
、PeriodIndex
添加了day_of_year
属性(兼容性别名dayofyear
)(GH 9605)添加了
set_flags()
方法,用于在 Series 或 DataFrame 上设置表格范围的标志(GH 28394)DataFrame.applymap()
现在支持na_action
参数(GH 23803)io.sql.get_schema()
现在支持schema
关键字参数,用于在创建表语句中添加 schema(GH 28486)DataFrame.explode()
和Series.explode()
现在支持展开集合(set)(GH 35614)DataFrame.hist()
现在支持时间序列(datetime)数据(GH 32590)Styler.set_table_styles()
现在允许直接设置行和列的样式并支持链式调用(GH 35607)Rolling.mean()
和Rolling.sum()
使用 Kahan 求和来计算平均值以避免数值问题(GH 10319, GH 11645, GH 13254, GH 32761, GH 36031)DatetimeIndex.searchsorted()
、TimedeltaIndex.searchsorted()
、PeriodIndex.searchsorted()
以及具有 datetime-like dtype 的Series.searchsorted()
现在将尝试将字符串参数(列表式和标量)转换为匹配的 datetime-like 类型(GH 36346)添加了
IntegerArray.prod()
、IntegerArray.min()
和IntegerArray.max()
方法(GH 33790)在具有扩展类型的
DataFrame
上调用 NumPy ufunc 现在在可能的情况下保留扩展类型(GH 23743)在多个
DataFrame
对象上调用接受两个输入的 NumPy ufunc 现在会进行对齐,与Series
上的二进制操作和 ufuncs 的行为一致(GH 23743)。此更改已在 pandas 1.2.1 中回滚,不对齐 DataFrame 的行为已被弃用,请参阅1.2.1 版本发布说明。在可能的情况下,
RangeIndex.difference()
和RangeIndex.symmetric_difference()
将返回RangeIndex
而非Int64Index
(GH 36564)DataFrame.to_parquet()
现在支持 parquet 格式中列的MultiIndex
(GH 34777)read_parquet()
新增了use_nullable_dtypes=True
选项,用于在可能的情况下对结果 DataFrame 使用以pd.NA
作为缺失值指示符的可空 dtype(默认为False
,且仅适用于engine="pyarrow"
)(GH 31242)添加了
Rolling.sem()
和Expanding.sem()
方法来计算平均值的标准误差(GH 26476)Rolling.var()
和Rolling.std()
使用 Kahan 求和和 Welford 方法来避免数值问题(GH 37051)DataFrame.corr()
和DataFrame.cov()
使用 Welford 方法来避免数值问题 (GH 37448)DataFrame.plot()
现在能识别用于scatter
和hexbin
类型图表的xlabel
和ylabel
参数 (GH 37001)DataFrame.to_parquet()
在未传递path
参数时现在返回一个bytes
对象 (GH 37105)Rolling
现在支持固定窗口的closed
参数 (GH 34315)DatetimeIndex
和Series
带有datetime64
或datetime64tz
dtypes 现在支持std
(GH 37436)Window
现在通过灵活的关键字参数支持,支持win_type
中的所有 Scipy 窗口类型 (GH 34556)testing.assert_index_equal()
现在有一个check_order
参数,允许以顺序无关的方式检查索引 (GH 37478)read_csv()
支持压缩文件的内存映射 (GH 37621)DataFrame.groupby()
和DataFrame.resample()
的min
,max
,first
和last
函数增加了对min_count
关键字的支持 (GH 37821, GH 37768)当给定无效的合并列定义时,改进了
DataFrame.merge()
的错误报告 (GH 16228)通过实现 Kahan Summation (卡汉求和法),提高了
Rolling.skew()
,Rolling.kurt()
,Expanding.skew()
和Expanding.kurt()
的数值稳定性 (GH 6929)改进了使用
axis=1
子集化DataFrameGroupBy
列的错误报告 (GH 37725)为
DataFrame.merge()
和DataFrame.join()
实现了cross
方法 (GH 5401)当使用
chunksize
/iterator
调用read_csv()
,read_sas()
和read_json()
时,它们可以作为上下文管理器在with
语句中使用 (GH 38225)增加了可用于 Excel 导出样式设置的命名颜色列表,启用了所有 CSS4 颜色 (GH 38247)
值得注意的错误修复#
这些是可能导致显著行为变化的错误修复。
DataFrame 约简的一致性#
DataFrame.any()
和 DataFrame.all()
在使用 bool_only=True
时,现在会逐列决定是否排除对象 dtype 的列,而不是检查 *所有* 对象 dtype 的列是否可以被视为布尔值。
这避免了病态行为,即在列的子集上应用约简可能导致更大的 Series 结果。请参阅 (GH 37799)。
In [24]: df = pd.DataFrame({"A": ["foo", "bar"], "B": [True, False]}, dtype=object)
In [25]: df["C"] = pd.Series([True, True])
以前的行为:
In [5]: df.all(bool_only=True)
Out[5]:
C True
dtype: bool
In [6]: df[["B", "C"]].all(bool_only=True)
Out[6]:
B False
C True
dtype: bool
新的行为:
In [26]: In [5]: df.all(bool_only=True)
Out[26]:
C True
Length: 1, dtype: bool
In [27]: In [6]: df[["B", "C"]].all(bool_only=True)
Out[27]:
C True
Length: 1, dtype: bool
其他带有 numeric_only=None
的 DataFrame 约简也将避免这种病态行为 (GH 37827)
In [28]: df = pd.DataFrame({"A": [0, 1, 2], "B": ["a", "b", "c"]}, dtype=object)
以前的行为:
In [3]: df.mean()
Out[3]: Series([], dtype: float64)
In [4]: df[["A"]].mean()
Out[4]:
A 1.0
dtype: float64
新的行为:
In [3]: df.mean()
Out[3]:
A 1.0
dtype: float64
In [4]: df[["A"]].mean()
Out[4]:
A 1.0
dtype: float64
此外,带有 numeric_only=None
的 DataFrame 约简现在将与其对应的 Series 约简保持一致。特别是,对于 Series 方法会引发 TypeError
的约简,DataFrame 约简现在会将该列视为非数值类型,而不是转换为可能具有不同语义的 NumPy 数组 (GH 36076, GH 28949, GH 21020)。
In [29]: ser = pd.Series([0, 1], dtype="category", name="A")
In [30]: df = ser.to_frame()
以前的行为:
In [5]: df.any()
Out[5]:
A True
dtype: bool
新的行为:
In [5]: df.any()
Out[5]: Series([], dtype: bool)
Python 最低版本要求提高#
pandas 1.2.0 支持 Python 3.7.1 及更高版本 (GH 35214)。
依赖项最低版本要求提高#
一些依赖项的最低支持版本已更新 (GH 35214)。如果已安装,我们现在要求
包 |
最低版本 |
必需 |
已更改 |
---|---|---|---|
numpy |
1.16.5 |
X |
X |
pytz |
2017.3 |
X |
X |
python-dateutil |
2.7.3 |
X |
|
bottleneck |
1.2.1 |
||
numexpr |
2.6.8 |
X |
|
pytest (dev) |
5.0.1 |
X |
|
mypy (dev) |
0.782 |
X |
对于可选库,通常建议使用最新版本。下表列出了 pandas 开发过程中当前正在测试的每个库的最低版本。低于最低测试版本范围的可选库可能仍然有效,但不被视为支持。
包 |
最低版本 |
已更改 |
---|---|---|
beautifulsoup4 |
4.6.0 |
|
fastparquet |
0.3.2 |
|
fsspec |
0.7.4 |
|
gcsfs |
0.6.0 |
|
lxml |
4.3.0 |
X |
matplotlib |
2.2.3 |
X |
numba |
0.46.0 |
|
openpyxl |
2.6.0 |
X |
pyarrow |
0.15.0 |
X |
pymysql |
0.7.11 |
X |
pytables |
3.5.1 |
X |
s3fs |
0.4.0 |
|
scipy |
1.2.0 |
|
sqlalchemy |
1.2.8 |
X |
xarray |
0.12.3 |
X |
xlrd |
1.2.0 |
X |
xlsxwriter |
1.0.2 |
X |
xlwt |
1.3.0 |
X |
pandas-gbq |
0.12.0 |
其他 API 变更#
对于 Datetime-like
Index
子类,Series.sort_values()
和Index.sort_values()
的降序排序现在是稳定的。这会影响在多列上对 DataFrame 进行排序、使用产生重复项的键函数进行排序或使用Index.sort_values()
请求排序索引时的排序顺序。使用Series.value_counts()
时,缺失值的计数不再强制位于重复计数列表的最后。相反,其位置对应于原始 Series 中的位置。使用Index.sort_values()
对 Datetime-likeIndex
子类进行排序时,NaTs 以前会忽略na_position
参数并排序到开头。现在它们遵循na_position
参数,默认值为last
,与其他Index
子类相同 (GH 35992)向
Categorical.take()
,DatetimeArray.take()
,TimedeltaArray.take()
或PeriodArray.take()
传递无效的fill_value
现在会引发TypeError
,而不是ValueError
(GH 37733)向带有
CategoricalDtype
的Series.shift()
传递无效的fill_value
现在会引发TypeError
,而不是ValueError
(GH 37733)尝试向
IntervalIndex.insert()
或CategoricalIndex.insert()
插入无效值现在会引发TypeError
,而不是ValueError
(GH 37733)尝试对带有
CategoricalIndex
的 Series 使用无效的fill_value
进行 reindex 现在会引发TypeError
,而不是ValueError
(GH 37733)带有包含非类别值的索引的
CategoricalIndex.append()
现在会进行类型转换而不是引发TypeError
(GH 38098)
弃用#
MultiIndex.set_codes()
和MultiIndex.set_levels()
中弃用参数inplace
(GH 35626)弃用所有
Index
子类中copy()
方法的参数dtype
。请改用astype()
方法来更改 dtype (GH 35853)弃用
MultiIndex.copy()
中的参数levels
和codes
。请改用set_levels()
和set_codes()
方法 (GH 36685)弃用
pandas.io.date_converters
中的日期解析函数parse_date_time()
,parse_date_fields()
,parse_all_fields()
和generic_parser()
,它们将在未来版本中移除;请改用to_datetime()
(GH 35741)弃用
DataFrame.lookup()
,它将在未来版本中移除,请改用DataFrame.melt()
和DataFrame.loc()
(GH 35224)方法
Index.to_native_types()
已弃用。请改用.astype(str)
(GH 28867)弃用使用单个 datetime-like 字符串对
DataFrame
行进行索引,例如df[string]
(鉴于它是索引行还是选择列存在歧义),请改用df.loc[string]
(GH 36179)弃用
Index.is_all_dates()
(GH 27744)未来版本中,
Series.str.replace()
的regex
参数的默认值将从True
更改为False
。此外,当设置regex=True
时,单字符正则表达式将 *不* 被视为字面字符串 (GH 24804)弃用
DataFrame
和Series
之间比较操作的自动对齐,例如在执行frame == ser
之前,先执行frame, ser = frame.align(ser, axis=1, copy=False)
(GH 28759)未来版本中,
Rolling.count()
使用min_periods=None
时将默认使用窗口大小 (GH 31302)弃用在 DataFrame 上使用“外层”ufuncs 返回 4d ndarray 的行为。请先转换为 ndarray (GH 23743)
弃用使用原生
datetime
对象对有时区信息的DatetimeIndex
进行切片索引,以匹配标量索引行为 (GH 36148)弃用
Index.ravel()
返回np.ndarray
的行为,未来将返回同一索引上的视图 (GH 19956)弃用在
to_timedelta()
中使用带有 'M', 'Y' 或 'y' 的单位字符串 (GH 36666)弃用
Index
方法&
,|
和^
分别作为集合操作Index.intersection()
,Index.union()
和Index.symmetric_difference()
的行为,未来它们将表现为逐元素的布尔操作,与Series
行为一致。请改用具名的集合方法 (GH 36758)弃用
Categorical.is_dtype_equal()
和CategoricalIndex.is_dtype_equal()
,它们将在未来版本中移除 (GH 37545)弃用
Series.slice_shift()
和DataFrame.slice_shift()
,请改用Series.shift()
或DataFrame.shift()
(GH 37601)弃用对无序的
DatetimeIndex
对象使用索引中不存在的键进行部分切片,此行为将在未来版本中移除 (GH 18531)弃用
PeriodIndex.astype()
中的how
关键字,它将在未来版本中移除,请改用index.to_timestamp(how=how)
(GH 37982)弃用
Index
子类(DatetimeIndex
,TimedeltaIndex
, 和PeriodIndex
除外)的Index.asi8()
方法 (GH 37877)弃用
Categorical.remove_unused_categories()
的inplace
参数,它将在未来版本中移除 (GH 37643)弃用
DataFrame.info()
的null_counts
参数,并替换为show_counts
。它将在未来版本中移除 (GH 37999)
对未对齐的 DataFrame 调用 NumPy ufuncs
在 pandas 1.2.0 中,对未对齐的 DataFrame 调用 NumPy ufuncs 的行为发生了变化(在调用 ufunc 之前对输入进行对齐),但在 pandas 1.2.1 中此更改已回滚。现在弃用了不对齐的行为,更多详情请参阅1.2.1 版本说明。
性能改进#
从包含许多字符串元素的数组创建 dtype 为
str
或StringDtype
的 DataFrame 或 Series 时性能提升 (GH 36304, GH 36317, GH 36325, GH 36432, GH 37371)使用
numba
引擎时,DataFrameGroupBy.agg()
和SeriesGroupBy.agg()
性能改进 (GH 35759)从大型字典创建
Series.map()
时性能改进 (GH 34717)使用
numba
引擎时,DataFrameGroupBy.transform()
和SeriesGroupBy.transform()
性能改进 (GH 36240)对于
float
dtype
列,使用非纳秒时间单位时to_datetime()
性能改进 (GH 20445)在
IntervalArray
上设置值时性能改进 (GH 36310)内部索引方法
_shallow_copy()
现在使新索引和原始索引共享缓存属性,避免在其中一个创建后再次创建。这可以加速依赖于创建现有索引副本的操作 (GH 36840)RollingGroupby.count()
性能改进 (GH 35625)固定窗口的
Rolling.min()
和Rolling.max()
性能略微下降 (GH 36567)在 python 3.8+ 中使用
protocol=5
时,DataFrame.to_pickle()
的峰值内存使用量减少 (GH 34244)当对象具有许多索引标签时,
dir
调用更快,例如dir(ser)
(GH 37450)ExpandingGroupby
性能改进 (GH 37064)Series.astype()
和DataFrame.astype()
方法针对Categorical
的性能提升 (GH 8628)DataFrame.groupby()
方法针对float
dtype
的性能提升 (GH 28303),底层哈希函数的变化可能导致基于浮点数的索引在遇到相同值时的排序发生变化 (例如Index.value_counts()
)pd.isin()
对于输入元素超过1e6的情况的性能提升 (GH 36611)DataFrame.__setitem__()
使用类列表索引器时的性能提升 (GH 37954)read_json()
现在在指定chunksize
时避免将整个文件读入内存 (GH 34548)
错误修复#
Categorical#
Categorical.fillna()
将总是返回一个副本,无论是否有 NA 需要填充都会验证传入的填充值,并且不允许使用NaT
作为数值类别的填充值 (GH 36530)Categorical.__setitem__()
中的错误,在使用元组值进行设置时错误地引发了异常 (GH 20439)CategoricalIndex.equals()
中的错误,错误地将非类别项转换为np.nan
(GH 37667)CategoricalIndex.where()
中的错误,错误地将非类别项设置为np.nan
而不是引发TypeError
(GH 37977)Categorical.to_numpy()
和np.array(categorical)
中的错误,对于时区敏感的datetime64
类别,错误地丢弃了时区信息而不是转换为 object dtype (GH 38136)
日期时间相关#
DataFrame.combine_first()
中的错误,当日期时间类列不在原始DataFrame
中时,它会将其他DataFrame
中的该列转换为整数 (GH 28481)DatetimeArray.date
中的错误,在使用只读后备数组时会引发ValueError
(GH 33530)NaT
比较中的错误,在无效的不等式比较时未能引发TypeError
(GH 35046)DateOffset
中的错误,当输入值超出正常范围(例如months=12
)时,从 pickle 文件重建的属性与原始对象不同 (GH 34511)DatetimeIndex.get_slice_bound()
中的错误,不接受datetime.date
对象或与时区敏感的DatetimeIndex
进行比较的简单Timestamp
(GH 35690)DatetimeIndex.slice_locs()
中的错误,不接受datetime.date
对象 (GH 34077)DatetimeIndex.searchsorted()
,TimedeltaIndex.searchsorted()
,PeriodIndex.searchsorted()
和Series.searchsorted()
中的错误,其datetime64
,timedelta64
或Period
dtype 中NaT
值的放置与 NumPy 不一致 (GH 36176, GH 36254)DatetimeArray
,TimedeltaArray
和PeriodArray
方法__setitem__
中的不一致,将字符串数组转换为日期时间类标量,但不将标量字符串转换 (GH 36261)DatetimeArray.take()
中的错误,错误地允许带有不匹配时区的fill_value
(GH 37356)DatetimeIndex.shift
中的错误,在移动空索引时错误地引发了异常 (GH 14811)Timestamp
和DatetimeIndex
在时区敏感和非时区敏感对象之间的比较现在遵循标准库datetime
的行为,对于!=
/==
返回True
/False
,对于不等式比较则引发异常 (GH 28507)DatetimeIndex.equals()
和TimedeltaIndex.equals()
中的错误,错误地将int64
索引视为相等 (GH 36744)Series.to_json()
,DataFrame.to_json()
和read_json()
现在在orient
结构为table
时实现时区解析 (GH 35973)astype()
现在尝试直接从object
转换到datetime64[ns, tz]
,并从字符串推断时区 (GH 35973)TimedeltaIndex.sum()
和Series.sum()
中的错误,对于空的索引或 Series,其timedelta64
dtype 返回NaT
而不是Timedelta(0)
(GH 31751)DatetimeArray.shift()
中的错误,错误地允许带有不匹配时区的fill_value
(GH 37299)将带有非零
offset
的BusinessDay
添加到非标量对象时的错误 (GH 37457)to_datetime()
中的错误,在使用只读数组时错误地引发了异常 (GH 34857)Series.isin()
中的错误,对于datetime64[ns]
dtype 和DatetimeIndex.isin()
,错误地将整数转换为日期时间 (GH 36621)Series.isin()
中的错误,对于datetime64[ns]
dtype 和DatetimeIndex.isin()
,未能将时区敏感和非时区敏感的日期时间始终视为不同 (GH 35728)Series.isin()
中的错误,对于PeriodDtype
dtype 和PeriodIndex.isin()
,未能将具有不同PeriodDtype
的参数始终视为不同 (GH 37528)
Timedelta#
TimedeltaIndex
,Series
和DataFrame
中涉及timedelta64
dtypes 且分母为NaT
的整除操作中的错误 (GH 35529)Timedelta
和to_datetime()
中解析 ISO 8601 持续时间时的错误 (GH 29773, GH 36204)to_timedelta()
中的错误,在使用只读数组时错误地引发了异常 (GH 34857)
时区#
date_range()
中的错误,在使用ambiguous=False
的有效输入时,引发了AmbiguousTimeError
(GH 35297)Timestamp.replace()
中的错误,丢失了 fold 信息 (GH 37610)
数值#
to_numeric()
中的错误,浮点精度不正确 (GH 31364)DataFrame.any()
中的错误,在使用axis=1
和bool_only=True
时忽略了bool_only
关键字 (GH 32432)Series.equals()
中的错误,当 NumPy 数组与标量进行比较时引发了ValueError
(GH 35267)Series
中的错误,当两个 Series 都具有具有不同时区的DatetimeIndex
时,执行算术操作时这些索引会被错误地更改 (GH 33671)pandas.testing
模块函数中的错误,在使用check_exact=False
时对复杂数值类型无效 (GH 28235)DataFrame.__rmatmul__()
错误处理中的错误,报告了转置后的形状 (GH 21581)Series
弹性算术方法中的错误,当与list
,tuple
或np.ndarray
进行操作时,结果的名称不正确 (GH 36760)IntegerArray
与timedelta
和np.timedelta64
对象相乘时的错误 (GH 36870)MultiIndex
与元组比较时的错误,错误地将元组视为类数组 (GH 21517)DataFrame.diff()
中的错误,对于包含NaT
值的datetime64
dtypes,未能正确填充NaT
结果 (GH 32441)IntervalArray
与Series
比较时的错误,没有返回 Series (GH 36908)DataFrame
中的错误,允许与类数组列表进行算术操作,结果不确定。行为已更改为引发ValueError
(GH 36702)DataFrame.std()
中的错误,对于timedelta64
dtype 和skipna=False
(GH 37392)DataFrame.min()
和DataFrame.max()
中的错误,对于datetime64
dtype 和skipna=False
(GH 36907)DataFrame.idxmax()
和DataFrame.idxmin()
中的错误,对于混合 dtypes 错误地引发了TypeError
(GH 38195)
转换#
DataFrame.to_dict()
中的错误,在使用orient='records'
时现在为日期时间类列返回 Python 原生的 datetime 对象 (GH 21256)Series.astype()
中的错误,在存在pd.NA
值时,从string
到float
的转换引发了异常 (GH 37626)
字符串#
Series.to_string()
,DataFrame.to_string()
和DataFrame.to_latex()
中的错误,当index=False
时添加了前导空格 (GH 24980)to_numeric()
中的错误,在尝试转换仅包含数值字符串和NA
的 string dtype Series 时引发了TypeError
(GH 37262)
区间#
DataFrame.replace()
和Series.replace()
中的错误,其中Interval
dtypes 会被转换为 object dtypes (GH 34871)IntervalIndex.take()
中的错误,在使用负索引和fill_value=None
时 (GH 37330)IntervalIndex.putmask()
中的错误,对于日期时间类 dtype,错误地转换为 object dtype (GH 37968)IntervalArray.astype()
中的错误,在使用CategoricalDtype
对象时错误地丢失了 dtype 信息 (GH 37984)
索引#
PeriodIndex.get_loc()
中的错误,对于非日期类字符串错误地引发了ValueError
而不是KeyError
,导致Series.__getitem__()
,Series.__contains__()
和Series.loc.__getitem__()
中出现类似错误 (GH 34240)Index.sort_values()
中的错误,当传入空值时,该方法会尝试比较缺失值而中断,而不是将它们推到排序顺序的末尾 (GH 35584)Index.get_indexer()
和Index.get_indexer_non_unique()
中的错误,返回了int64
数组而不是intp
(GH 36359)DataFrame.sort_index()
中的错误,将参数 ascending 作为列表传递给单层索引时结果不正确 (GH 32334)在
DataFrame.reset_index()
中存在一个 bug,在使用含有MultiIndex
且某个层级是Categorical
dtype 且存在缺失值的输入时,会错误地抛出ValueError
异常 (GH 24206)使用布尔掩码对日期时间类型值进行索引时,有时会错误地返回视图而非副本,这是一个 bug (GH 36210)
在
DataFrame.__getitem__()
和DataFrame.loc.__getitem__()
中,处理具有IntervalIndex
列和数字索引器时存在一个 bug (GH 26490)在
Series.loc.__getitem__()
中,处理非唯一MultiIndex
和空列表索引器时存在一个 bug (GH 13691)对带有
MultiIndex
且层级名称为"0"
的Series
或DataFrame
进行索引时存在一个 bug (GH 37194)在
Series.__getitem__()
中,使用无符号整型数组作为索引器时存在一个 bug,会产生错误结果或分段故障,而非抛出KeyError
异常 (GH 37218)在
Index.where()
中存在一个 bug,会错误地将数字值转换为字符串 (GH 37591)在
DataFrame.loc()
中,当索引器为具有负步长的切片时会返回空结果,这是一个 bug (GH 38071)当索引为
object
dtype 且给定的数字标签存在于索引中时,Series.loc()
和DataFrame.loc()
会抛出异常,这是一个 bug (GH 26491)在
DataFrame.loc()
中,将 `loc` 应用于MultiIndex
的单个层级时存在一个 bug,会返回请求的键以及缺失值 (GH 27104)对带有
CategoricalIndex
的Series
或DataFrame
使用包含 NA 值的列表状索引器进行索引时存在一个 bug (GH 37722)在
DataFrame.loc.__setitem__()
中,扩展具有混合 dtype 的空DataFrame
时存在一个 bug (GH 37932)在
DataFrame.xs()
中存在一个 bug,会忽略对列设置的droplevel=False
参数 (GH 19056)在
DataFrame.reindex()
中,处理 `tolerance` 非 `None` 或 `method="nearest"` 的空 DataFrame 时存在一个 bug,会错误地抛出IndexingError
(GH 27315)对带有
CategoricalIndex
的Series
或DataFrame
使用包含索引的categories
中存在但索引本身中不存在元素的列表状索引器进行索引时存在一个 bug,未能抛出KeyError
(GH 37901)向具有数字
Index
列的DataFrame
插入布尔标签时存在一个 bug,会错误地转换为整数 (GH 36319)在
DataFrame.iloc()
和Series.iloc()
在__setitem__
中对齐对象时存在一个 bug (GH 22046)在
MultiIndex.drop()
中存在一个 bug,在给定的标签部分存在时不会抛出异常 (GH 37820)在
DataFrame.loc()
中存在一个 bug,在给定缺失组合且其余层级使用slice(None)
时不会抛出KeyError
异常 (GH 19556)在
DataFrame.loc()
中,使用非整数切片选择MultiIndex
中的值时会抛出TypeError
异常,这是一个 bug (GH 25165, GH 24263)在
Series.at()
中存在一个 bug,在索引是单层MultiIndex
时会返回包含一个元素的Series
而非标量值 (GH 38053)在
DataFrame.loc()
中存在一个 bug,在索引器的顺序与用于过滤的MultiIndex
顺序不同时,会错误地返回和分配元素 (GH 31330, GH 34603)在
DataFrame.loc()
和DataFrame.__getitem__()
中,当列是单层MultiIndex
时会抛出KeyError
异常,这是一个 bug (GH 29749)在
Series.__getitem__()
和DataFrame.__getitem__()
中,处理IntervalIndex
时会抛出空的KeyError
异常(不包含缺失的键),这是一个 bug (GH 27365)在带有
CategoricalIndex
的DataFrame
或Series
上设置新标签时存在一个 bug,当新标签不在索引的categories
中时会错误地抛出TypeError
异常 (GH 38098)在
Series.loc()
和Series.iloc()
中,向等长的object
Series 中插入列表状的np.array
、list
或tuple
时会抛出ValueError
异常,这是一个 bug (GH 37748, GH 37486)在
Series.loc()
和Series.iloc()
中存在一个 bug,在使用列表状的ExtensionArray
设置object
Series 的值时,会设置所有值而非插入 (GH 38271)
缺失值#
在
SeriesGroupBy.transform()
中的 bug 已修复,现在可以正确处理dropna=False
时的缺失值 (GH 35014)在
Series.nunique()
中,设置dropna=True
且同时存在NA
和None
缺失值时存在一个 bug,会返回错误结果 (GH 37566)在
Series.interpolate()
中存在一个 bug,在使用 `pad` 和 `backfill` 方法时,参数limit_area
和limit_direction
不起作用 (GH 31048)
MultiIndex#
在
DataFrame.xs()
中,与IndexSlice
一起使用时会抛出TypeError
异常,并显示消息"Expected label or tuple of labels"
,这是一个 bug (GH 35301)在
DataFrame.reset_index()
中,索引中含有NaT
值时会抛出ValueError
异常,并显示消息"cannot convert float NaN to integer"
,这是一个 bug (GH 36541)在
DataFrame.combine_first()
中,与包含字符串和NaN
值的MultiIndex
一起使用时会抛出TypeError
异常,这是一个 bug (GH 36562)在
MultiIndex.drop()
中存在一个 bug,在输入不存在的键时会丢弃NaN
值 (GH 18853)在
MultiIndex.drop()
中存在一个 bug,在索引包含重复项且未排序时,会丢弃比预期更多的数据 (GH 33494)
输入/输出 (I/O)#
read_sas()
在失败时不再泄露资源 (GH 35566)在
DataFrame.to_csv()
和Series.to_csv()
中存在一个 bug,在与包含b
的mode
参数结合使用文件名调用时会导致ValueError
(GH 35058)在
read_csv()
中,使用float_precision='round_trip'
时存在一个 bug,无法处理decimal
和thousands
参数 (GH 35365)to_pickle()
和read_pickle()
曾会关闭用户提供的文件对象 (GH 35679)to_csv()
总是将'gzip'
的压缩参数传递给gzip.GzipFile
(GH 28103)to_csv()
不支持没有文件名的二进制文件对象的 zip 压缩 (GH 35058)to_csv()
和read_csv()
对于内部转换为文件对象的类路径对象,未遵守compression
和encoding
参数 (GH 35677, GH 26124, GH 32392)DataFrame.to_pickle()
、Series.to_pickle()
和read_pickle()
不支持文件对象的压缩 (GH 26237, GH 29054, GH 29570)在
LongTableBuilder.middle_separator()
中存在一个 bug,会在 LaTeX 文档的表格目录中重复 LaTeX 长表格条目 (GH 34360)在
read_csv()
中,使用engine='python'
时存在一个 bug,如果第一行包含多个项目且第一个元素以 BOM 开头,则会截断数据 (GH 36343)从
read_gbq()
中移除了private_key
和verbose
参数,因为pandas-gbq
已不再支持它们 (GH 34654, GH 30200)已将 pytables 的最低版本提升至 3.5.1,以避免
read_hdf()
中的ValueError
(GH 24839)在
read_table()
和read_csv()
中,当delim_whitespace=True
且sep=default
时存在一个 bug (GH 36583)在
DataFrame.to_json()
和Series.to_json()
中,在使用lines=True
和orient='records'
时存在一个 bug,记录的最后一行未追加“换行符” (GH 36888)在
read_parquet()
中,处理固定偏移时区时存在一个 bug。时区的字符串表示未被识别 (GH 35997, GH 36004)在
DataFrame.to_html()
、DataFrame.to_string()
和DataFrame.to_latex()
中,在同时指定float_format
时会忽略na_rep
参数,这是一个 bug (GH 9046, GH 13828)复杂数输出渲染时显示过多尾随零,这是一个 bug (GH 36799)
在
HDFStore
中,导出具有datetime64[ns, tz]
dtype 的空 DataFrame 到固定的 HDF5 存储时会抛出TypeError
异常,这是一个 bug (GH 20594)在
HDFStore
中,导出具有datetime64[ns, tz]
dtype 的 Series 到固定的 HDF5 存储时会丢弃时区信息,这是一个 bug (GH 20594)read_csv()
在engine="c"
且指定编码时会关闭用户提供的二进制文件句柄 (GH 36980)在
DataFrame.to_hdf()
中存在一个 bug,在设置dropna=True
时不会丢弃含有缺失值的行 (GH 35719)在
read_html()
中存在一个 bug,在为io
参数提供pathlib.Path
参数时会抛出TypeError
异常 (GH 37705)DataFrame.to_excel()
、Series.to_excel()
、DataFrame.to_markdown()
和Series.to_markdown()
现在支持写入 fsspec URLs,例如 S3 和 Google Cloud Storage (GH 33987)在
read_fwf()
中,设置skip_blank_lines=True
时存在一个 bug,不会跳过空行 (GH 37758)使用
read_json()
并设置dtype=False
时,将缺失值解析为NaN
而非None
(GH 28501)read_fwf()
在compression=None
时会推断压缩格式,这与其他read_*
函数不一致 (GH 37909)DataFrame.to_html()
在处理ExtensionDtype
列时会忽略formatters
参数 (GH 36525)已将 xarray 的最低版本提升至 0.12.3,以避免引用已移除的
Panel
类 (GH 27101, GH 37983)DataFrame.to_csv()
会重新打开同时实现了os.PathLike
的文件状句柄 (GH 38125)将含有缺失值的切片
pyarrow.Table
转换为 DataFrame 时存在一个 bug (GH 38525)在
read_sql_table()
中,在列名包含百分号时存在一个 bug,会抛出sqlalchemy.exc.OperationalError
(GH 37517)
Period#
在
DataFrame.replace()
和Series.replace()
中存在一个 bug,会导致Period
dtype 转换为 object dtype (GH 34871)
绘图 (Plotting)#
在
DataFrame.plot()
中存在一个 bug,在设置subplots=True
时会旋转 x 轴刻度标签,即使 x 轴不是非规则时间序列 (GH 29460)Bug in
DataFrame.plot()
where a marker letter in thestyle
keyword sometimes caused aValueError
(GH 21003)Bug in
DataFrame.plot.bar()
andSeries.plot.bar()
where ticks positions were assigned by value order instead of using the actual value for numeric or a smart ordering for string (GH 26186, GH 11465). This fix has been reverted in pandas 1.2.1, see What’s new in 1.2.1 (January 20, 2021)Twinned axes were losing their tick labels which should only happen to all but the last row or column of ‘externally’ shared axes (GH 33819)
Bug in
Series.plot()
andDataFrame.plot()
was throwing aValueError
when the Series or DataFrame was indexed by aTimedeltaIndex
with a fixed frequency and the x-axis lower limit was greater than the upper limit (GH 37454)Bug in
DataFrameGroupBy.boxplot()
whensubplots=False
would raise aKeyError
(GH 16748)Bug in
DataFrame.plot()
andSeries.plot()
was overwriting matplotlib’s shared y axes behavior when nosharey
parameter was passed (GH 37942)Bug in
DataFrame.plot()
was raising aTypeError
withExtensionDtype
columns (GH 32073)
Styler#
Bug in
Styler.render()
HTML was generated incorrectly because of formatting error inrowspan
attribute, it now matches with w3 syntax (GH 38234)
Groupby/resample/rolling#
Bug in
DataFrameGroupBy.count()
andSeriesGroupBy.sum()
returningNaN
for missing categories when grouped on multipleCategoricals
. Now returning0
(GH 35028)Bug in
DataFrameGroupBy.apply()
that would sometimes throw an erroneousValueError
if the grouping axis had duplicate entries (GH 16646)Bug in
DataFrame.resample()
that would throw aValueError
when resampling from"D"
to"24H"
over a transition into daylight savings time (DST) (GH 35219)Bug when combining methods
DataFrame.groupby()
withDataFrame.resample()
andDataFrame.interpolate()
raising aTypeError
(GH 35325)Bug in
DataFrameGroupBy.apply()
where a non-nuisance grouping column would be dropped from the output columns if another groupby method was called before.apply
(GH 34656)Bug when subsetting columns on a
DataFrameGroupBy
(e.g.df.groupby('a')[['b']])
) would reset the attributesaxis
,dropna
,group_keys
,level
,mutated
,sort
, andsqueeze
to their default values (GH 9959)Bug in
DataFrameGroupBy.tshift()
failing to raiseValueError
when a frequency cannot be inferred for the index of a group (GH 35937)Bug in
DataFrame.groupby()
does not always maintain column index name forany
,all
,bfill
,ffill
,shift
(GH 29764)Bug in
DataFrameGroupBy.apply()
raising error withnp.nan
group(s) whendropna=False
(GH 35889)Bug in
Rolling.sum()
returned wrong values when dtypes where mixed between float and integer andaxis=1
(GH 20649, GH 35596)Bug in
Rolling.count()
returnednp.nan
withFixedForwardWindowIndexer
as window,min_periods=0
and only missing values in the window (GH 35579)Bug where
Rolling
produces incorrect window sizes when using aPeriodIndex
(GH 34225)Bug in
DataFrameGroupBy.ffill()
andDataFrameGroupBy.bfill()
where aNaN
group would return filled values instead ofNaN
whendropna=True
(GH 34725)Bug in
RollingGroupby.count()
where aValueError
was raised when specifying theclosed
parameter (GH 35869)Bug in
DataFrameGroupBy.rolling()
returning wrong values with partial centered window (GH 36040)Bug in
DataFrameGroupBy.rolling()
returned wrong values with time aware window containingNaN
. RaisesValueError
because windows are not monotonic now (GH 34617)Bug in
Rolling.__iter__()
where aValueError
was not raised whenmin_periods
was larger thanwindow
(GH 37156)Using
Rolling.var()
instead ofRolling.std()
avoids numerical issues forRolling.corr()
whenRolling.var()
is still within floating point precision whileRolling.std()
is not (GH 31286)Bug in
DataFrameGroupBy.quantile()
andResampler.quantile()
raisedTypeError
when values were of typeTimedelta
(GH 29485)Bug in
Rolling.median()
andRolling.quantile()
returned wrong values forBaseIndexer
subclasses with non-monotonic starting or ending points for windows (GH 37153)Bug in
DataFrame.groupby()
droppednan
groups from result withdropna=False
when grouping over a single column (GH 35646, GH 35542)Bug in
DataFrameGroupBy.head()
,DataFrameGroupBy.tail()
,SeriesGroupBy.head()
, andSeriesGroupBy.tail()
would raise when used withaxis=1
(GH 9772)Bug in
DataFrameGroupBy.transform()
would raise when used withaxis=1
and a transformation kernel (e.g. “shift”) (GH 36308)Bug in
DataFrameGroupBy.resample()
using.agg
with sum produced different result than just calling.sum
(GH 33548)Bug in
DataFrameGroupBy.apply()
dropped values onnan
group when returning the same axes with the original frame (GH 38227)Bug in
DataFrameGroupBy.quantile()
couldn’t handle with arraylikeq
when grouping by columns (GH 33795)Bug in
DataFrameGroupBy.rank()
withdatetime64tz
or period dtype incorrectly casting results to those dtypes instead of returningfloat64
dtype (GH 38187)
Reshaping#
Bug in
DataFrame.crosstab()
was returning incorrect results on inputs with duplicate row names, duplicate column names or duplicate names between row and column labels (GH 22529)Bug in
DataFrame.pivot_table()
withaggfunc='count'
oraggfunc='sum'
returningNaN
for missing categories when pivoted on aCategorical
. Now returning0
(GH 31422)Bug in
concat()
andDataFrame
constructor where input index names are not preserved in some cases (GH 13475)Bug in func
crosstab()
when using multiple columns withmargins=True
andnormalize=True
(GH 35144)Bug in
DataFrame.stack()
where an empty DataFrame.stack would raise an error (GH 36113). Now returning an empty Series with empty MultiIndex.Bug in
Series.unstack()
. Now a Series with single level of Index trying to unstack would raise aValueError
(GH 36113)Bug in
DataFrame.agg()
withfunc={'name':<FUNC>}
incorrectly raisingTypeError
whenDataFrame.columns==['Name']
(GH 36212)Bug in
Series.transform()
would give incorrect results or raise when the argumentfunc
was a dictionary (GH 35811)Bug in
DataFrame.pivot()
did not preserveMultiIndex
level names for columns when rows and columns are both multiindexed (GH 36360)Bug in
DataFrame.pivot()
modifiedindex
argument whencolumns
was passed butvalues
was not (GH 37635)Bug in
DataFrame.join()
returned a non deterministic level-order for the resultingMultiIndex
(GH 36910)Bug in
DataFrame.combine_first()
caused wrong alignment with dtypestring
and one level ofMultiIndex
containing onlyNA
(GH 37591)Fixed regression in
merge()
on mergingDatetimeIndex
with empty DataFrame (GH 36895)Bug in
DataFrame.apply()
not setting index of return value whenfunc
return type isdict
(GH 37544)Bug in
DataFrame.merge()
andpandas.merge()
returning inconsistent ordering in result forhow=right
andhow=left
(GH 35382)Bug in
merge_ordered()
couldn’t handle list-likeleft_by
orright_by
(GH 35269)Bug in
merge_ordered()
returned wrong join result when length ofleft_by
orright_by
equals to the rows ofleft
orright
(GH 38166)Bug in
merge_ordered()
didn’t raise when elements inleft_by
orright_by
not exist inleft
columns orright
columns (GH 38167)Bug in
DataFrame.drop_duplicates()
not validating bool dtype forignore_index
keyword (GH 38274)
ExtensionArray#
Fixed bug where
DataFrame
column set to scalar extension type via a dict instantiation was considered an object type rather than the extension type (GH 35965)Fixed bug where
astype()
with equal dtype andcopy=False
would return a new object (GH 28488)Fixed bug when applying a NumPy ufunc with multiple outputs to an
IntegerArray
returningNone
(GH 36913)Fixed an inconsistency in
PeriodArray
’s__init__
signature to those ofDatetimeArray
andTimedeltaArray
(GH 37289)Reductions for
BooleanArray
,Categorical
,DatetimeArray
,FloatingArray
,IntegerArray
,PeriodArray
,TimedeltaArray
, andPandasArray
are now keyword-only methods (GH 37541)Fixed a bug where a
TypeError
was wrongly raised if a membership check was made on anExtensionArray
containing nan-like values (GH 37867)
Other#
Bug in
DataFrame.replace()
andSeries.replace()
incorrectly raising anAssertionError
instead of aValueError
when invalid parameter combinations are passed (GH 36045)Bug in
DataFrame.replace()
andSeries.replace()
with numeric values and stringto_replace
(GH 34789)Fixed metadata propagation in
Series.abs()
and ufuncs called on Series and DataFrames (GH 28283)Bug in
DataFrame.replace()
andSeries.replace()
incorrectly casting fromPeriodDtype
to object dtype (GH 34871)Fixed bug in metadata propagation incorrectly copying DataFrame columns as metadata when the column name overlaps with the metadata name (GH 37037)
在
Series.dt
,Series.str
访问器,DataFrame.duplicated
,DataFrame.stack
,DataFrame.unstack
,DataFrame.pivot
,DataFrame.append
,DataFrame.diff
,DataFrame.applymap
和DataFrame.update
方法中修复了元数据传播 (GH 28283, GH 37381)修复了在使用
DataFrame.__getitem__
选择列时发生的元数据传播问题 (GH 28283)Index.intersection()
在处理非Index
类型时,未能正确设置返回的Index
的名称的 Bug (GH 38111)RangeIndex.intersection()
在某些边缘情况下,未能正确设置返回的Index
的名称的 Bug (GH 38197)Index.difference()
在某些边缘情况下,未能正确设置返回的Index
的名称的 Bug (GH 38268)Index.union()
在操作数是Index
或其他列表状类型时行为不同的 Bug (GH 36384)Index.intersection()
在处理不匹配的数值 dtypes 时,会转换为object
dtype 而非最小公共 dtype 的 Bug (GH 38122)现在,将具有 2 个或更多维度的数组传递给
Series
构造函数时,会引发更具体的ValueError
而非普通的Exception
(GH 35744)dir
的 Bug,其中dir(obj)
未显示 pandas 对象实例上定义的属性 (GH 37173)Index.drop()
在索引存在重复值时引发InvalidIndexError
的 Bug (GH 38051)RangeIndex.difference()
在某些情况下返回Int64Index
而非应返回RangeIndex
的 Bug (GH 38028)修复了
assert_series_equal()
在比较日期时间类型数组与等效的非扩展 dtype 数组时的 Bug (GH 37609)is_bool_dtype()
在传递有效字符串(如"boolean"
)时会引发异常的 Bug (GH 38386)修复了当
DataFrame
的列是具有未使用类别的CategoricalIndex
时,逻辑运算符引发ValueError
的回归 Bug (GH 38367)
贡献者#
共有 257 人为此版本贡献了补丁。姓名旁带有“+”号的人是首次贡献补丁。
21CSM +
AbdulMAbdi +
Abhiraj Hinge +
Abhishek Mangla +
Abo7atm +
Adam Spannbauer +
Albert Villanova del Moral
Alex Kirko
Alex Lim +
Alex Thorne +
Aleš Erjavec +
Ali McMaster
Amanda Dsouza +
Amim Knabben +
Andrew Wieteska
Anshoo Rajput +
Anthony Milbourne
Arun12121 +
Asish Mahapatra
Avinash Pancham +
BeanNan +
Ben Forbes +
Brendan Wilby +
Bruno Almeida +
Byron Boulton +
Chankey Pathak
Chris Barnes +
Chris Lynch +
Chris Withers
Christoph Deil +
Christopher Hadley +
Chuanzhu Xu
Coelhudo +
Dan Moore
Daniel Saxton
David Kwong +
David Li +
David Mrva +
Deepak Pandey +
Deepyaman Datta
Devin Petersohn
Dmitriy Perepelkin +
Douglas Hanley +
Dāgs Grīnbergs +
Eli Treuherz +
Elliot Rampono +
Erfan Nariman
Eric Goddard
Eric Leung +
Eric Wieser
Ethan Chen +
Eve +
Eyal Trabelsi +
Fabian Gebhart +
Fangchen Li
Felix Claessen +
Finlay Maguire +
Florian Roscheck +
Gabriel Monteiro
Gautham +
Gerard Jorgensen +
Gregory Livschitz
Hans
Harsh Sharma
Honfung Wong +
Igor Gotlibovych +
Iqrar Agalosi Nureyza
Irv Lustig
Isaac Virshup
Jacob Peacock
Jacob Stevens-Haas +
Jan Müller +
Janus
Jeet Parekh
Jeff Hernandez +
Jeff Reback
Jiaxiang
Joao Pedro Berno Zanutto +
Joel Nothman
Joel Whittier +
John Karasinski +
John McGuigan +
Johnny Pribyl +
Jonas Laursen +
Jonathan Shreckengost +
Joris Van den Bossche
Jose +
JoseNavy +
Josh Temple +
Jun Kudo +
Justin Essert
Justin Sexton +
Kaiqi Dong
Kamil Trocewicz +
Karthik Mathur
Kashif +
Kenny Huynh
Kevin Sheppard
Kumar Shivam +
Leonardus Chen +
Levi Matus +
Lucas Rodés-Guirao +
Luis Pinto +
Lynch +
Marc Garcia
Marco Gorelli
Maria-Alexandra Ilie +
Marian Denes
Mark Graham +
Martin Durant
Matt Roeschke
Matthew Roeschke
Matthias Bussonnier
Maxim Ivanov +
Mayank Chaudhary +
MeeseeksMachine
Meghana Varanasi +
Metehan Kutlu +
Micael Jarniac +
Micah Smith +
Michael Marino
Miroslav Šedivý
Mohammad Jafar Mashhadi
Mohammed Kashif +
Nagesh Kumar C +
Nidhi Zare +
Nikhil Choudhary +
Number42
Oleh Kozynets +
OlivierLuG
Pandas Development Team
Paolo Lammens +
Paul Ganssle
Pax +
Peter Liu +
Philip Cerles +
Pranjal Bhardwaj +
Prayag Savsani +
Purushothaman Srikanth +
Qbiwan +
Rahul Chauhan +
Rahul Sathanapalli +
Rajat Bishnoi +
Ray Bell
Reshama Shaikh +
Richard Shadrach
Robert Bradshaw
Robert de Vries
Rohith295
S Mono +
S.TAKENO +
Sahid Velji +
Sam Cohen +
Sam Ezebunandu +
Sander +
Sarthak +
Sarthak Vineet Kumar +
Satrio H Wicaksono +
Scott Lasley
Shao Yang Hong +
Sharon Woo +
Shubham Mehra +
Simon Hawkins
Sixuan (Cherie) Wu +
Souris Ash +
Steffen Rehberg
Suvayu Ali
Sven
SylvainLan +
T. JEGHAM +
Terji Petersen
Thomas Dickson +
Thomas Heavey +
Thomas Smith
Tobias Pitters
Tom Augspurger
Tomasz Sakrejda +
Torsten Wörtwein +
Ty Mick +
UrielMaD +
Uwe L. Korn
Vikramaditya Gaonkar +
VirosaLi +
W.R +
Warren White +
Wesley Boelrijk +
William Ayd
Yanxian Lin +
Yassir Karroum +
Yong Kai Yi +
Yuanhao Geng +
Yury Mikhaylov +
Yutaro Ikeda
Yuya Takashina +
Zach Brookler +
Zak Kohler +
ZhihuiChen0903 +
abmyii
alexhtn +
asharma13524 +
attack68
beanan +
chinhwee
cleconte987
danchev +
ebardie +
edwardkong
elliot rampono +
estasney +
gabicca
geetha-rangaswamaiah +
gfyoung
guru kiran
hardikpnsp +
icanhazcodeplz +
ivanovmg +
jbrockmendel
jeschwar
jnecus
joooeey +
junk +
krajatcl +
lacrosse91 +
leo +
lpkirwin +
lrjball
lucasrodes +
ma3da +
mavismonica +
mlondschien +
mzeitlin11 +
nguevara +
nrebena
parkdj1 +
partev
patrick
realead
rxxg +
samilAyoub +
sanderland
shawnbrown
sm1899 +
smartvinnetou
ssortman +
steveya +
taytzehao +
tiagohonorato +
timhunderwood
tkmz-n +
tnwei +
tpanza +
vineethraj510 +
vmdhhh +
xinrong-databricks +
yonas kassa +
yonashub +
Ádám Lippai +