“Entfernen Sie doppelte Zeilen in Pandas” Code-Antworten

Entfernen Sie Duplikate mit Pandas

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

Löschen Sie die gesamte Zeile, während Sie Duplikate mit Python entfernen.

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

Drop -Duplikate Pandas erste Spalte

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

Entfernen Sie die doppelte Zeile in DF

df = df.drop_duplicates()
Sachin

Dataframe löschen doppelte Zeilen mit demselben Spaltenwert

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

Entfernen Sie doppelte Zeilen in Pandas

# 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

Ähnliche Antworten wie “Entfernen Sie doppelte Zeilen in Pandas”

Fragen ähnlich wie “Entfernen Sie doppelte Zeilen in Pandas”

Weitere verwandte Antworten zu “Entfernen Sie doppelte Zeilen in Pandas” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen