python - Use result from one dataframe to find data in another dataframe in pandas -


i learning pandas.
have 2 dataframe a,b
2 col of data come row , col in b. how select data in b based on a' result.
a's result should have 2 cols. first result of col of b , second row of b
thank you.

i manage result now. still not full understand pandas dataframe indexing.

raw_eps.loc[ raw_eps.loc[:,'act_rpt_code'] == before_market, ('ticker','date') ] 

the example dummy data
example a's result follow:

result a:     name      date 0      123  10/22/15 2      245  10/27/15 

the dataframe b follow:

data in b:     date      123   245  789 0   10/22/15  ccc   ddd  odo 1   10/27/15  eee   fff  jdj 1   11/21/15  ttt   www  ppp 

the result want using name , date in a's find data in b

ccc   ddd   eee   fff 

try this:

dfa= pd.dataframe({'name':[123,456],'id':[1,2]}) dfb= pd.dataframe({123:['aaa','bbb'],456:['lll','jjj'],'id':[1,2]}) 

you can pass values want index .loc

dfb.loc[:,dfa.name.tolist()] 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

json - Gson().fromJson(jsonResult, Myobject.class) return values in 0's -