久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何“選擇不同的"?跨越 pandas 中的多個數據

How to quot;select distinctquot; across multiple data frame columns in pandas?(如何“選擇不同的?跨越 pandas 中的多個數據框列?)
本文介紹了如何“選擇不同的"?跨越 pandas 中的多個數據框列?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在尋找一種與 SQL 等效的方法

I'm looking for a way to do the equivalent to the SQL

SELECT DISTINCT col1, col2 FROM dataframe_table

pandas sql 比較沒有關于 distinct 的任何內容.

The pandas sql comparison doesn't have anything about distinct.

.unique() 僅適用于單個列,所以我想我可以連接這些列,或者將它們放在列表/元組中并以這種方式進行比較,但這似乎是熊貓應該做的以更本土的方式進行.

.unique() only works for a single column, so I suppose I could concat the columns, or put them in a list/tuple and compare that way, but this seems like something pandas should do in a more native way.

我是否遺漏了一些明顯的東西,或者沒有辦法做到這一點?

Am I missing something obvious, or is there no way to do this?

推薦答案

您可以使用drop_duplicates 方法來獲取 DataFrame 中的唯一行:

You can use the drop_duplicates method to get the unique rows in a DataFrame:

In [29]: df = pd.DataFrame({'a':[1,2,1,2], 'b':[3,4,3,5]})

In [30]: df
Out[30]:
   a  b
0  1  3
1  2  4
2  1  3
3  2  5

In [32]: df.drop_duplicates()
Out[32]:
   a  b
0  1  3
1  2  4
3  2  5

如果您只想使用某些列來確定唯一性,您還可以提供 subset 關鍵字參數.請參閱文檔字符串.

You can also provide the subset keyword argument if you only want to use certain columns to determine uniqueness. See the docstring.

這篇關于如何“選擇不同的"?跨越 pandas 中的多個數據框列?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 成人国产精品入口免费视频 | 色资源站 | 黄色在线免费观看视频 | 国产精品1区 | 天天宗合网 | 中文亚洲视频 | 波多野结衣一区二区 | 亚洲精品一区二区三区在线观看 | 欧美专区日韩 | 女人夜夜春| 国产一区二区三区四区在线观看 | 人人澡视频 | 国产精品久久久久久妇女6080 | 97国产精品视频人人做人人爱 | 亚州一区二区三区 | 欧美一区二区三区视频 | 久久国产精品网站 | 97国产超碰 | 亚洲午夜视频 | 人人射人人插 | 二区不卡 | 国产高清在线精品一区二区三区 | 色综合久久天天综合网 | 精品久久精品 | 午夜国产一区 | 中文字幕在线电影观看 | 午夜在线观看视频 | 天天操夜夜操免费视频 | 国产精品日韩欧美一区二区三区 | 天天综合久久 | 一区二区免费 | 久久中文字幕av | 国产在线观看一区二区 | 欧美一区二区三区四区视频 | 中文字幕在线视频精品 | 看a网站 | 搞av.com| 亚洲+变态+欧美+另类+精品 | 日朝毛片| 天堂综合网 | 午夜性色a√在线视频观看9 |