MATERIAL Prod_Date Prod_Qty Status
0 107LPY04 2022-12-01 0 Yes
1 051DPY03 2022-12-01 4 Unavailable
2 040LPY72 2022-12-01 0 Yes
3 025LPY61 2022-12-01 0 Yes
4 034LPY05 2022-12-01 0 Yes
The above table is my data. It is a 6251 rows data.
I want to make a new dataframe in which I will get only rows with status "Unavailable".
I used the command
df2 = (df[df.Status == "Unavailable"])
df2
But I get an empty dataframe. There are total 6 Unavailable in Status Column. Hence I should get 6 rows as my output.
CodePudding user response:
Use Series.str.strip
for remove trailing spaces:
df[df.Status.str.strip() == "Unavailable"]
CodePudding user response:
df_new = df[df["Status"] == "Unavalible"]