“Hapus baris duplikat di panda” Kode Jawaban

Hapus duplikat dengan panda

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

hapus seluruh baris sambil menghapus duplikat dengan ular surut

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

Jatuhkan kolom panda pertama

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

Hapus baris duplikat di DF

df = df.drop_duplicates()
Sachin

DataFrame Hapus baris duplikat dengan nilai kolom yang sama

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

Hapus baris duplikat di panda

# 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

Jawaban yang mirip dengan “Hapus baris duplikat di panda”

Pertanyaan yang mirip dengan “Hapus baris duplikat di panda”

Lebih banyak jawaban terkait untuk “Hapus baris duplikat di panda” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya