“Usuń zduplikowane rzędy w pandy” Kod odpowiedzi

Usuń duplikaty z pandy

import pandas as pd

# Drop all duplicates in the DataFrame
df = df.drop_duplicates()

# Drop all duplicates in a specific column of the DataFrame
df = df.drop_duplicates(subset = "column")

# Drop all duplicate pairs in DataFrame
df = df.drop_duplicates(subset = ["column", "column2"])

# Display DataFrame
print(df)
Elisabeth Engering

Usuń cały wiersz, usuwając duplikaty za pomocą Pythona

result_df = df.drop_duplicates(subset=['Column1', 'Column2'], keep='first')
print(result_df)
Doubtful Dugong

Upuść duplikatów pierwszej kolumny pand

import pandas as pd 
  
# making data frame from csv file 
data = pd.read_csv("employees.csv") 
  
# sorting by first name 
data.sort_values("First Name", inplace = True) 
  
# dropping ALL duplicte values 
data.drop_duplicates(subset ="First Name",keep = False, inplace = True) 
  
# displaying data 
print(data)
Sachin

Usuń zduplikowane wiersz w DF

df = df.drop_duplicates()
Sachin

DataFrame usuń duplikat wierszy o tej samej wartości kolumny

df = df.drop_duplicates(subset=['Column1', 'Column2'], keep='first')

# Exemple
import pandas as pd
df = pd.DataFrame({"A":["foo", "foo", "foo", "bar"], "B":[0,1,1,1], "C":["A","A","B","A"]})
df.drop_duplicates(subset=['A', 'C'], keep=False)
Xenophobic Xenomorph

Usuń zduplikowane rzędy w pandy

# drop duplicates pandas first column
import pandas as pd 
  
# making data frame from csv file 
data = pd.read_csv("employees.csv") 
  
# sorting by first name 
data.sort_values("First Name", inplace = True) 
  
# dropping ALL duplicte values 
data.drop_duplicates(subset ="First Name",keep = False, inplace = True) 
  
# displaying data 
print(data)

# remove duplicate row in df
df = df.drop_duplicates()

#remove duplicate columns python dataframepython by Happy Hawk on May 28 2020 Comment
df = df.loc[:,~df.columns.duplicated()]

# dataframe delete duplicate rows with same column value
df = df.drop_duplicates(subset=['Column1', 'Column2'], keep='first')

# Exemple
import pandas as pd
df = pd.DataFrame({"A":["foo", "foo", "foo", "bar"], "B":[0,1,1,1], "C":["A","A","B","A"]})
df.drop_duplicates(subset=['A', 'C'], keep=False)
Splendid Sardine

Odpowiedzi podobne do “Usuń zduplikowane rzędy w pandy”

Pytania podobne do “Usuń zduplikowane rzędy w pandy”

Więcej pokrewnych odpowiedzi na “Usuń zduplikowane rzędy w pandy” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu