本文簡要介紹
pyspark.pandas.Series.compare
的用法。用法:
Series.compare(other: pyspark.pandas.series.Series, keep_shape: bool = False, keep_equal: bool = False) → pyspark.pandas.frame.DataFrame
與另一個係列進行比較並顯示差異。
- other:Series
要比較的對象。
- keep_shape:布爾值,默認為 False
如果為真,則保留所有行和列。否則,僅保留具有不同值的那些。
- keep_equal:布爾值,默認為 False
如果為真,則結果保持相等的值。否則,相等的值顯示為 NaN。
- DataFrame
參數:
返回:
注意:
匹配 NaNs 不會顯示為差異。
例子:
>>> from pyspark.pandas.config import set_option, reset_option >>> set_option("compute.ops_on_diff_frames", True) >>> s1 = ps.Series(["a", "b", "c", "d", "e"]) >>> s2 = ps.Series(["a", "a", "c", "b", "e"])
對齊列上的差異
>>> s1.compare(s2).sort_index() self other 1 b a 3 d b
保留所有原始行
>>> s1.compare(s2, keep_shape=True).sort_index() self other 0 None None 1 b a 2 None None 3 d b 4 None None
保留所有原始行以及所有原始值
>>> s1.compare(s2, keep_shape=True, keep_equal=True).sort_index() self other 0 a a 1 b a 2 c c 3 d b 4 e e
>>> reset_option("compute.ops_on_diff_frames")
相關用法
- Python pyspark Series.combine_first用法及代碼示例
- Python pyspark Series.copy用法及代碼示例
- Python pyspark Series.count用法及代碼示例
- Python pyspark Series.corr用法及代碼示例
- Python pyspark Series.cumsum用法及代碼示例
- Python pyspark Series.cat.ordered用法及代碼示例
- Python pyspark Series.cat.as_unordered用法及代碼示例
- Python pyspark Series.cummax用法及代碼示例
- Python pyspark Series.cat.set_categories用法及代碼示例
- Python pyspark Series.cummin用法及代碼示例
- Python pyspark Series.cat.rename_categories用法及代碼示例
- Python pyspark Series.cat.as_ordered用法及代碼示例
- Python pyspark Series.cumprod用法及代碼示例
- Python pyspark Series.clip用法及代碼示例
- Python pyspark Series.cat.reorder_categories用法及代碼示例
- Python pyspark Series.cat.remove_categories用法及代碼示例
- Python pyspark Series.cat.add_categories用法及代碼示例
- Python pyspark Series.cat.categories用法及代碼示例
- Python pyspark Series.cat.codes用法及代碼示例
- Python pyspark Series.cat.remove_unused_categories用法及代碼示例
- Python pyspark Series.asof用法及代碼示例
- Python pyspark Series.to_frame用法及代碼示例
- Python pyspark Series.rsub用法及代碼示例
- Python pyspark Series.mod用法及代碼示例
- Python pyspark Series.str.join用法及代碼示例
注:本文由純淨天空篩選整理自spark.apache.org大神的英文原創作品 pyspark.pandas.Series.compare。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。