Home > other >  Selection of dataframe locate a particular problem
Selection of dataframe locate a particular problem

Time:01-09

By understanding dateframe line selection has been the weak, feel very uncomfortable, is a practical problem, consult everybody the teacher!!!!!
A column of a dateframe, to determine whether conform to the rules, does not conform to delete, what should I do? The index of df is a mess, there is no rule that
For aa in df [0] :
If fun (aa)=false:
Delete the aa traverse to the line


"Delete the aa traverse to the line" how do you write the code?

CodePudding user response:

Conditions to choose first, reoccupy index for

Df=pd read_csv (" new CSV ")
Remove_df=df [(df/" order status "==" failure ")]
Df=df drop (remove_df index)
Print (df)

CodePudding user response:

reference 1st floor CreateBig response:
conditions to choose first, then use the index for

Df=pd read_csv (" new CSV ")
Remove_df=df [(df/" order status "==" failure ")]
Df=df drop (remove_df index)
Print (df)


I am of the df index, such as the index=1 will have a lot of, will not delete the wrong?

CodePudding user response:

That would mistakenly deleted, if the index order is not very important to reset the index
Df. Reset_index (drop=True, inplace=True)

CodePudding user response:

Or don't delete, according to the condition directly to filter out a new dataframe
Sub_df=df [df [' column name ']. The map (fun)=false]
  • Related