“Eliminar filas duplicadas en pandas” Código de respuesta

Eliminar los duplicados con 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

Elimine toda la fila mientras elimine los duplicados con python

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

Dropplicate Pandas Primera columna

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

Eliminar la fila duplicada en DF

df = df.drop_duplicates()
Sachin

DataFrame Eliminar filas duplicadas con el mismo valor de columna

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

Eliminar filas duplicadas 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

Respuestas similares a “Eliminar filas duplicadas en pandas”

Preguntas similares a “Eliminar filas duplicadas en pandas”

Más respuestas relacionadas con “Eliminar filas duplicadas en pandas” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código