I have a pandas dataframe (called smalls) that is repurposed several times to create several network diagrams from a dataset. I am trying to set the color of the nodes in one of the diagrams based on entity type and need to query the original dataframe. However, when I do so it results in a series, which I then cannot perform a comparison on. How can I modify the first line below to only give me the first entry from the dataframe (all of the others will be the same)?
temp=smalls.Role[smalls.Entity==big_nodes_order[i]]
print(temp)
10 Threat
11 Threat
12 Threat
Name: Role, dtype: object
或者,您可以使用.head()
方法:
temp=smalls.Role[smalls.Entity==big_nodes_order[i]].head(1)
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.