Message Boards Message Boards

0
|
5060 Views
|
6 Replies
|
5 Total Likes
View groups...
Share
Share this post:

[Solved] Mapping Length over each class in EntityClassList["Chemical"]

Posted 3 years ago

As of now I have to find the individual lengths of each chemical class in this data set individually, but I was looking for a way that I could find the length of each individual chemical class at once. enter image description here

POSTED BY: N Ibrahim
6 Replies
Posted 3 years ago

As an Association

AssociationMap[EntityValue[#, "EntityCount"] &, EntityClassList["Chemical"]]
POSTED BY: Rohit Namjoshi
Posted 3 years ago

Thank you both. This is exactly what I was looking for!

POSTED BY: N Ibrahim
Posted 3 years ago

Another option would be to use a singe Map:

Map[
 {#, EntityValue[#, "EntityCount"]} &,
 EntityClassList["Chemical"]
 ]
POSTED BY: Mike Besso

then you use Thread for both outputs, here is the whole operation

list = EntityClassList["Chemical"];
len = EntityValue[#, "EntityCount"] & /@ list;
Thread[{list, len}]
POSTED BY: Ahmed Elbanna
Posted 3 years ago

Thank you so much! Would it be possible that the numerical values in the output have their corresponding chemical class next to them so it is easier to undestand?

POSTED BY: N Ibrahim

Hi

Try this

list = EntityClassList["Chemical"];
EntityValue[#, "EntityCount"] & /@ list
POSTED BY: Ahmed Elbanna
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