So I have a dataset which draws from another larger dataset. It is a gene expression dataset, some of the samples in themsaller dataset are of intereste because they are taken from a region of the brain which is part of a particular network of interest. The unique identifier is called well
d = {'network_name': [dDMN, Salience, Salience, Visual, dDNM], 'well_id': [11, 52, 37, 14, 89]}
small_df = pd.DataFrame(data=d)
bigd = {'Brain_region': [Hp, PFC, dlPFC, V2, Striatum, PFC, V1, Cerebellum], 'well_id': [54, 45, 89, 14, 11, 52, 23, 37]}
big_df = pd.DataFrame(data=bigd)
So say I am interested in the Salience network. I want the index of the well_id which match the list of Well_ids which are labeled as Salience in network_name. I've found a way to pull the well_id and create a list of well_ids.
def pull_well_id (network):
#takes in the sample annotation datasets as a list of dataframes and the network of interest
#returns the well ids of all the samples in the list
well_ids=list(small_df[small_df['network_name']==network]['well_id'])
return well_ids
IDs=pull_well_id('Salience')
Now I want to get the index of the well_ids which match this list in big_df. I have tried...
ID_index=list(big_df[big_df['well_id']==IDs.index.values)
But this does not work at all. Any suggestions
与isin
核对
big_df.index[big_df.well_id.isin(IDs)]
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.