“Hapus baris dari panda” Kode Jawaban

Hapus baris dari DataFrame Python

df.drop(df.index[-2])
df.drop(df.index[[3, 4]])
df.drop(['row_1', 'row_2'])
df.drop('column_1', axis=1)
df[df.name != 'cell']
JJSSEECC

DataFrame Delete Row

df.drop(df.index[2])
Confused Cod

Hapus kolom dari python DataFrame

df = df.drop(df.columns[[0, 1, 3]], axis=1)  # df.columns is zero-based pd.Index 
Magnificent Mongoose

Hapus baris dari panda

df = df[df["column_name"].isin([0, 1, 3, 4])]
# into isin we put the value we want to mantain
John D'oh

Jatuhkan kolom dari DataFrame

#to drop by column number instead of by column label, try this to delete, e.g. the 1st, 2nd and 4th columns
df = df.drop(df.columns[[0, 1, 3]], axis=1)  # df.columns is zero-based pd.Index 
Desert Trap

Baris drop panda

 current table:
  Modules	Subjects
0	DSM020	Data programming in Python
1	DSM030	Mathematics and statistics
2	DSM040	Machine learning
3	DSM010	Big data analysis
4	DSM050	Data visualisation
5	DSM060	Data science research topics
6	DSM070	Blockchain programming
7	DSM080	Mathematics of financial markets
8	DSM110	R for data science
9	DSM120	Financial data modelling
10	DSM500	Final project
11	DSM100	Artificial 

#dropping rows using indexes
list_of_subjects.drop([2,5,6,8,10,11])

output:
	Modules	Subjects
0	DSM020	Data programming in Python
1	DSM030	Mathematics and statistics
3	DSM010	Big data analysis
4	DSM050	Data visualisation
7	DSM080	Mathematics of financial markets
9	DSM120	Financial data modelling
Clever Crocodile

Jawaban yang mirip dengan “Hapus baris dari panda”

Pertanyaan yang mirip dengan “Hapus baris dari panda”

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

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya