“Retirez les lignes en double en pandas” Réponses codées

Retirez les doublons avec des 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

Supprimer la ligne entière tout en supprimant les doublons avec Python '

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

Drop Duplicate Pandas First Colonne

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

Retirez la ligne en double en DF

df = df.drop_duplicates()
Sachin

DataFrame Supprimer les lignes en double avec la même valeur de colonne

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

Retirez les lignes en double en 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

Réponses similaires à “Retirez les lignes en double en pandas”

Questions similaires à “Retirez les lignes en double en pandas”

Plus de réponses similaires à “Retirez les lignes en double en pandas” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code