0

i have a data set presented as follow: FORMAT TO CONVERT

I would like to classify values in part name and material column based on their value in ID but I am confused about the code to use in python. I know it is a conditional code but I don't know which one to use exactly. The final result should look like this final result

Sai Chandra Gadde
  • 2,242
  • 1
  • 3
  • 15
  • Please do no use images of data, provide a DataFrame constructor: [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – mozway May 04 '22 at 07:47

1 Answers1

0

You want this ?

df['Part name']=np.where(df['ID']=='P',df['Part name'],np.nan)
df['Material']=np.where(df['ID']=='M',df['Material'],np.nan)
DataSciRookie
  • 798
  • 1
  • 3
  • 12