Message Boards Message Boards

0
|
3567 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

How to keep the keyvalues only in an association?

Posted 3 years ago

I associated the symbol to the pe ratio before filtering to keep track of the symbols kept. Now I would like to disassociate the pair and grab just the symbols. My data:

In[96]:= dAll = FinancialData[ "Stocks", "Members"];
Length[dAll]

Out[97]= 42380

In[98]:= dNN = Pick[dAll, StringMatchQ[dAll, {"NYSE:*", "NASDAQ:*"}]] ;
Length[dNN]

Out[99]= 8605

In[100]:= dNNpe = FinancialData[dNN, "PERatio" ];

In[101]:= dNNpeA = AssociationThread[dNN, dNNpe] // DeleteMissing;
Length[dNNpeA]
dNNpeA[[1 ;; 10]]

Out[102]= 3021

Out[103]= <|"NASDAQ:AAME" -> 5.10256, "NASDAQ:AAON" -> 46.1241, 
 "NASDAQ:AAPL" -> 28.4729, "NASDAQ:AAWW" -> 4.78659, 
 "NASDAQ:ABCB" -> 8.29133, "NASDAQ:ABCL" -> 29.37, 
 "NASDAQ:ABMD" -> 102.444, "NASDAQ:ABST" -> 128.889, 
 "NASDAQ:ABTX" -> 10.3872, "NASDAQ:ACBI" -> 11.684|>

After filtering i have a paired list

In

dNNpeG100 = 
  Pick[dNNpeA, Table[dNNpeA[[i]] > 100, {i, Length[dNNpeA]}]];
Length[dNNpeG100]

Out[138]= 248

How would I disassociate the list and keep just the symbols??? I have tried without success the following:

dNNpeG100[[1]]
dNNpeG100[[All]]["KeyValue"] 
dNNpeG100[[2]] // "KeyAbsent"
dNNpeG100[[2, 1]] ;
POSTED BY: Raymond Low

I don’t fully understand your question but I think you’re looking for the functions Keys and Values.

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract