Group Abstract Group Abstract

Message Boards Message Boards

0
|
9.3K Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Apply UnitConvert to nested Entity data?

Posted 9 years ago
Attachments:
2 Replies

in addition to Vitaliy's long list of great options you can also do it with one function:

MapAt[UnitConvert[#, "light minutes"] &, planets, {All, 3}]

which says to map the UnitConvert over all the planet lists but apply it to the third element of each planet list.

POSTED BY: Neil Singer

There are numerous ways to post-process. After you got your data in au as

data=EntityValue[EntityClass["Planet",All],{"Name","Image","DistanceFromEarth"}];

You can use any of these methods and there probably many more:

data/.x_Quantity->UnitConvert[x,"LightMinutes"]

MapAt[UnitConvert[#,"LightMinutes"]&,#,3]&/@data

Transpose[MapAt[UnitConvert[#,"LightMinutes"]&,Transpose[data],3]]

Cases[data,{a_,b_,c_}:>{a,b,UnitConvert[c,"LightMinutes"]}]
POSTED BY: Vitaliy Kaurov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard