I'm currently working on a dataframe and in a certain column I have different categories of classes (organism taxonomy). In this class column there are 105 unique classes in the +/- 3000 rows. You can view each row as a species. Multiple species can belong to 1 class.
For the class "Unknown" in this class column, I would like to change the value of the column "Superkingdom_name" in each of the rows which have "Unknown" in the class column. How is this done?
I'm currently clueless of how to do this.
So I expect to change the value of "Superkingdom_name" for every row that has value "unknown" in the class column.
Thanks!
With the very limited information you have provided, I think you can use loc method. Assuming your data is stored in a df
:
df.loc[df['class'] == "Unknown", 'Superkingdom_name'] = "new_value"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.