# Data Formats in Wolfram|Alpha

Introduction | Obtaining Data Formats Programmatically |

Exploring Data Formats Interactively | Examples of Exposed Data |

## Introduction

In addition to its graphical results, Wolfram|Alpha can provide alternative representations that contain additional information or are well suited to particular tasks. These alternative representations are collectively referred to as data formats. Not all results have all these formats; indeed, it is difficult to conceive of a single result that could have all these representations. Therefore, there exist both interactive and programmatic mechanisms to determine and request the various formats.

There is a subgroup of the data formats known as "exposed data formats". Their purpose is to make it possible to extract useful data from Wolfram|Alpha. For example, the data points used to make a plot may be returned, allowing custom visualizations to be created. Some or all formatting, comments, and other extraneous details are omitted to focus on the data. The names of current exposed data formats as they appear in interactive menus are listed in the table, along with descriptions of the elements extracted.

Menu Name | Description |

Computable data | the data represented by the results, including numerical, textual, and mathematical elements; this format attempts to strip as much formatting as possible to make the result machine processible; this means Grid, Column, etc. are stripped, and dates are returned in the format of DateList |

Formatted data | the data represented by the results, including numerical, textual, and mathematical elements; it attempts to preserve the appearance of the result as much as possible, including the use of the special head |

Formula data | a list of mathematical and Wolfram Language expressions in the result, in held form |

Number data | a list of singleton numbers and the numeric portion of singleton quantities in the result |

Quantity data | a list of singleton quantities (numbers with units) in the result |

Sound data | a list of the sound objects appearing in the result |

Time series data | a list of time series appearing in the result |

The other data formats are more specialized. Two formats appear in menus as Input and Output. These provide Wolfram Language input and output corresponding to the graphical result, and are in fact used by the free-form input mechanism (= at the beginning of a line). The final format provides a plaintext representation of non-graphical elements in the result.

Menu Name | Description |

Input | a Wolfram Language expression for the computation that led to the result |

Output | an ordinary Wolfram Language expression representing the result |

Plaintext | a plaintext representation of the result |

## Exploring Data Formats Interactively

Both Wolfram|Alpha query and free-form input provide mechanisms to request the various data formats where available. Since Wolfram|Alpha query shows all results by default, it is often a more convenient method for accessing these formats.

### Wolfram|Alpha Query

#### Basic Workflow

Consider the following Wolfram|Alpha query.

Three results are generated. Each white area with a rounded gray border is referred to as a pod. Clicking the plus sign in the upper-right corner of each pod provides a context menu for requesting that pod in various formats. For example, the "Definite integral" pod has a context menu that looks like this:

The first two items, Formatted pod and Subpod content, are always available. The items after the first divider indicate that the pod contains Plaintext, Input, and Output. Finally, after the second divider, the available exposed data formats are listed—in this case, Computable data, Formatted data, and Formula data.

In[12]:= |

Out[12]= |

In[13]:= |

Out[13]= |

In[14]:= |

Out[14]= |

Clicking the plus sign for the "Visual representation of the integral" pod produces a much shorter menu. This pod has no available exposed data formats, and only Input of the other data formats.

#### Exposed Data Need Not Resemble the Graphical Result

In the previous example, the exposed data looks essentially the same as the result. This is not always the case. Consider the following query.

Clicking the plus sign in the "History" pod and selecting Formatted data produces the following. Instead of a plot, the actual data points used to create the plot are listed; the underlying data has been exposed.

In[16]:= |

Out[16]= |

The InputForm of the previous output contains the special formatting wrapper . This head, as well as the type of output to expect from exposed data formats, is discussed further in the section "Examples of Exposed Data".

In[17]:= |

Out[17]//InputForm= | |

#### The Structure of the Second Argument

It is worth noting the structure of the second argument to the WolframAlpha function in the cells generated by clicking the context menu. In all cases it is . The is a string created by Wolfram|Alpha to identify the pod, and is the name of a property to extract. The subpodid is an integer indicating the position of a particular result within the pod. All of the previous examples had a single subpod within the pod, so the index was always one. Here is an example of a query that produces multiple subpods per pod.

The thin gray line running horizontally between the two plots is the tell-tale sign of multiple subpods. In this case, selecting Input from the "Plots" pod context menu produces two calls to WolframAlpha, one for each subpod.

In[19]:= |

Out[19]= |

This syntax can be extended to extract multiple formats from multiple pods, as explained in the section "Obtaining Data Formats Programmatically".

### Free-Form Input

Consider the integration example from above entered using free-form input.

Out[20]= |

The first thing to notice is that the Integrate expression generated directly below the free-form expression is nothing other than the Wolfram Language input expression seen in the first example. This is precisely how the free-form input mechanism works: it searches for Wolfram Language input and output expressions in the results from Wolfram|Alpha and evaluates those expressions locally.

Clicking the plus sign to the right of the free-form expression reveals all the results. The Wolfram Language input expressions, if any, for each result are displayed directly above the result in a gray box. This is done precisely because the Wolfram Language input format plays such a central role in the free-form input mechanism.

Although only the Wolfram Language input expression is shown next to the pod, all the other formats are available from a context menu. To access, for example, the computable data for the integral, right-click it and select Copy As ▶ Computable data.

You can now paste the data anywhere you would like—for example, into the following cell.

You can produce an input cell similarly to how the context menu for Wolfram|Alpha query works by selecting Paste input for ▶ Computable data instead.

This will create, directly below the results, the following cell. However, unlike Wolfram|Alpha query, the cell will not automatically evaluate.

In[42]:= |

Out[42]= |

## Obtaining Data Formats Programmatically

### Data Formats as Subpod Properties

The data formats are properties associated with particular subpods, as the previous examples have shown. They can therefore be requested using the standard and syntaxes of the WolframAlpha function. The programmatic property names for the various formats are strings obtained from their respective menu names by combining the words in camel-case. Thus, Computable data becomes , Time series data becomes , Input becomes , and so forth.

### Determining Available Formats

The data formats available for a particular subpod are contained in the property of each subpod. This property can be computed in the same way as any other subpod property.

*input for the two "Plot" subpods.*

In[21]:= |

Out[21]= |

In[22]:= |

Out[22]= |

The list of formats returned by the property can then be used in place of the string to request the actual data.

In[23]:= |

Out[23]= |

As is standard with the WolframAlpha function, if you select a single property of a single subpod, only the value will be returned.

In[24]:= |

Out[24]= |

### Requesting Data Directly

Rather than first determining which formats are available and then requesting them, you can also request the data formats directly. This is typically accomplished using the syntax of the WolframAlpha function.

In[25]:= |

Out[25]= |

In[26]:= |

Out[26]= |

In[27]:= |

Out[27]= |

In[28]:= |

Out[28]= |

In[29]:= |

Out[29]= |

If you are interested in the exposed data, the argument to WolframAlpha will return all available exposed data in the normal form. Using ensures that if new exposed data formats are added, they will be listed as well.

In[30]:= |

Out[30]= |

The and arguments of WolframAlpha can be easily reproduced using the syntax of WolframAlpha.

In[31]:= |

Out[31]= |

In[32]:= |

Out[32]= |

In[14]:= |

Out[14]= |

In[15]:= |

Out[15]= |

In[16]:= |

Out[16]= |

## Examples of Exposed Data

### General Notes

Not all Wolfram|Alpha results have data format representations, much less any exposed data, although Wolfram|Alpha results are being refined to provide data formats all the time. Also, when there are multiple exposed data formats available, there are cases where two or even three of the formats coincide. This is all dependent on the contents of the individual pods. Generally speaking, computable data and formatted data are the most general; they are typically present if any exposed data is present, and they may contain heterogeneous data. The other formats seek to drill down and provide specific types of data and are therefore much more predictable. The examples following are organized according to the types of data that they contain.

### Quantities and Numbers

Like the Wolfram Language's Quantity object, quantities in Wolfram|Alpha consist of a number with a unit. It is possible to directly access either the whole quantity or just the numeric portion using exposed data. The first pod from the earlier financial example provides a nice illustration of how these are handled.

In[61]:= |

Out[61]= |

Formatted data and computable data give different takes on the entire result.

In[62]:= |

Out[62]= |

In[65]:= |

Out[65]= |

On the other hand, quantity data and number data return only the quantitative part of the result, ignoring the text.

In[66]:= |

Out[66]= |

In[67]:= |

Out[67]= |

### Time Series

History plots are the prototypical example of time series, which give a value for each in a series of dates. The following is the history plot seen earlier.

In[31]:= |

Out[31]= |

In[68]:= |

Out[68]= |

In[69]:= |

Out[69]//InputForm= | |

In[72]:= |

Out[72]= |

In[70]:= |

Out[70]= |

In[71]:= |

Out[71]= |

### Formulas

The introductory examples in "Exploring Data Formats Interactively" showed how formula data can return a single equation. It can, however, also return multiple equations, which the "Equation" pod of the following query does.

In[53]:= |

Out[53]= |

In[54]:= |

Out[54]= |

### Sounds

The pulsar LGM-1 has many interesting properties known to Wolfram|Alpha. One of these is an audio schematic of its pulsing.

In[55]:= |

Out[55]= |

For this particular pod, the only exposed data is sound data; this format is the one most likely to appear without corresponding formatted data or computable data.

In[56]:= |

Out[56]= |

In[57]:= |

Out[57]//InputForm= | |

Wolfram|Alpha can produce music in addition to sampled sounds.

In[58]:= |

Out[58]= |

In[59]:= |

Out[59]= |

In[60]:= |

Out[60]//InputForm= | |