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

刪除 *NEARLY* 重復(fù)的觀(guān)察 - Python

Removing *NEARLY* Duplicate Observations - Python(刪除 *NEARLY* 重復(fù)的觀(guān)察 - Python)
本文介紹了刪除 *NEARLY* 重復(fù)的觀(guān)察 - Python的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我正在嘗試刪除 pandas DataFrame 中的一些觀(guān)察結(jié)果,其中相似性幾乎為 100%,但不完全一致.見(jiàn)下圖:

I am attempting to remove some observations in a pandas DataFrame where the similarities are ALMOST 100% but not quite. See frame below:

注意John"、Mary"和Wesley"是如何出現(xiàn)的具有幾乎相同的觀(guān)察結(jié)果,但有一列不同.真實(shí)數(shù)據(jù)集有 15 列和 215,000 多個(gè)觀(guān)測(cè)值.在我可以直觀(guān)驗(yàn)證的所有情況下,相似之處同樣是:在 15 列中,其他觀(guān)察每次最多匹配 14 列.為了項(xiàng)目的目的,我決定刪除重復(fù)的觀(guān)察結(jié)果(并將它們存儲(chǔ)到另一個(gè) DataFrame 中,以防我的老板要求查看它們).

Notice how "John", "Mary", and "Wesley" have nearly identical observations, but have one column being different. The real data set has 15 columns, and 215,000+ observations. In all of the cases I could visually verify, the similarities were likewise: out of 15 columns, the other observation would match up to 14 columns, every time. For the purpose of the project I have decided to remove the repeated observations (and store them into another DataFrame just in case my boss asks to see them).

我顯然已經(jīng)想到了 remove_duplicates(keep='something'),但這行不通,因?yàn)橛^(guān)察結(jié)果并不完全相似.有沒(méi)有人遇到過(guò)這樣的問(wèn)題?有什么補(bǔ)救辦法嗎?

I have evidently thought of remove_duplicates(keep='something'), but that would not work since the observations are not ENTIRELY similar. Has anyone ever encounter such an issue? Any idea on a remedy?

推薦答案

關(guān)于列子集的簡(jiǎn)單循環(huán)怎么樣:

What about a simple loop over subset of columns :

import pandas as pd

df = pd.DataFrame(
        [
            ['John', 45, 85000, 'DC'],
            ['Netcha', 25, 48000, 'NYC'],
            ['Mary', 45, 85000, 'DC'],
            ['Wesley', 36, 72500, 'LA'],
            ['Porter', 22, 98750, 'Seattle'],
            ['John', 45, 105500, 'DC'],
            ['Mary', 28, 85000, 'DC'],
            ['Wesley', 36, 72500, 'Boston'],
        ], 
        columns=['Name', 'Age', 'Salary', 'City'])

cols = df.columns.tolist()
cols.remove('Name')

for col in cols:
    observed_cols = df.drop(col, axis=1).columns.tolist()
    df.drop_duplicates(observed_cols, keep='first', inplace=True)

print(df)

返回:

     Name  Age  Salary     City
0    John   45   85000       DC
1  Netcha   25   48000      NYC
2    Mary   45   85000       DC
3  Wesley   36   72500       LA
4  Porter   22   98750  Seattle

這篇關(guān)于刪除 *NEARLY* 重復(fù)的觀(guān)察 - Python的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區(qū)域周?chē)L制一個(gè)矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測(cè)和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個(gè)矩形邊界框中應(yīng)用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據(jù)文本方向檢測(cè)圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測(cè)圖像中矩形的中心和角度)
主站蜘蛛池模板: 99久久久久久 | 国产精品美女在线观看 | 亚欧洲精品在线视频免费观看 | 精品成人在线观看 | av大片在线观看 | av国产精品 | 亚洲国产精品一区二区久久 | 国产欧美在线播放 | 久久久综合色 | 亚洲另类视频 | 欧洲一区二区在线 | www.久草| 午夜视频网站 | 成人欧美一区二区三区在线播放 | 中文字幕中文字幕 | 国产视频一视频二 | 五月婷婷视频 | 国产激情三区 | 国产黄色av网站 | 国产精品精品久久久 | 日日夜夜精品视频 | 日韩精品一区二区三区视频播放 | 国产98色在线 | 日韩 | 欧美日韩国产一区 | 亚洲国产一区二区在线 | 91精品国产色综合久久 | 99精品电影| 精品日韩一区二区 | 日韩欧美国产精品 | 99久久婷婷国产综合精品电影 | 亚州精品天堂中文字幕 | 亚洲精品1区| 精品一区二区三区在线视频 | 国产日韩欧美一区 | 91精品国产91久久综合桃花 | 操久久 | 亚洲一区二区三区视频 | 午夜精品视频在线观看 | 日本不卡一区二区三区在线观看 | 国产毛片视频 | 99精品电影|