0

I have CountryData coming in via e.g.

Entity["Country", "Australia"][
  EntityProperty["Country", "GDP",
   {"CurrencyUnit" -> "Constant2000USDollar", 
    "TimeSeriesOperator" -> "AnnualGrowthRate"}
  ]
]

Which returns

-0.00383656% per year (* unit: percent per year *)

My desired output is -0.0000383656 (i.e. as purely a decimal number).

I am surprised by how hard it has been to find an answer. Despite this question being very simple, I can't find a way with Quantity, NumberForm, etc.

diomedesdata
  • 225
  • 1
  • 6
  • 5
    I'd just do QuantityMagnitude[r]/100 where r is your result you obtained from that long command. Mathematica graphics -0.0000383656 – Nasser Nov 28 '22 at 09:43
  • 1
    Simply take the first part of your result: yourresult[[1]] – Daniel Huber Nov 28 '22 at 10:08
  • @DanielHuber cool, simple solution. Is there a way one can investigate the structure/parts of an object that would have let me figure this out? – diomedesdata Nov 28 '22 at 12:34
  • 1
    Every object in MMA is like an array. With obi[[0]] you can get the head and with obi[[i,j..] all the parts. Note, this does not work for atomic objects , they consist of only the head. – Daniel Huber Nov 28 '22 at 12:43
  • 1
    Also with FullForm you can see the structure of the returnvalue: FullForm[r] gives you Quantity[-0.0038365585665900404`,Times["Percent",Power["Years",-1]]] – Mathias Nov 28 '22 at 17:32
  • Or also TreeForm if you want something more visual. TreeForm can be nice when you have nested structures. For example compare {{{s, l}}, {{u, {j}}}} // TreeForm with k[s + l] + o[u + m[j]] // TreeForm (the variables should not be assigned a value). That shows how symbolically a list, an expression or a wrapper it's basically the same with different letters. The only thing I would add is that mathematica functions sometimes treat lists differently than other objects but often functions that work for lists work for expressions. – userrandrand Nov 29 '22 at 02:14
  • Or if you want a nicer output maybe ExpressionTree but that one is newer and I do not know how reliable it is. – userrandrand Nov 29 '22 at 02:23
  • 1
    FullForm, TreeForm and ExpressionTree might lead to expressions that are too lengthy at times in which case you can consider InputForm after getting familiar with outputs of FullForm – userrandrand Nov 29 '22 at 02:29
  • 1
    FullForm, TreeForm and ExpressionTree might lead to expressions that are too lengthy at times in which case you can consider InputForm after getting familiar with outputs of FullForm. At a more advanced level note that some objects like Graphs that are AtomicQ might not seem to be when you look at the FullForm as it would seem that you could use Part or Replace. But FullForm just provides a visualization of the structure if the object is AtomicQ and does not show all of the information in the internal representation/code of the object. – userrandrand Nov 29 '22 at 02:35
  • For a recent discussion with ReplaceAll not working even though FullForm would suggest it to be possible see https://mathematica.stackexchange.com/q/275837/86543. For a list of Atomic objects see EntityClass["WolframLanguageSymbol", "Atomic"]//EntityList – userrandrand Nov 29 '22 at 02:41

1 Answers1

2

Collection of answers in the comments (many thanks to those commenters):

  1. QuantityMagnitude[%]
  2. %[[1]] or Part[%, 1]

And inspect the output with FullForm[%], TreeForm[%], and ExpressionTree[%].

diomedesdata
  • 225
  • 1
  • 6