# DataFrame Selectors Examples

## Example 1

```jsx
<Table
  options={{
    table: '> primary | frameBySeriesIndexes(0,1,3)'
  }},
  dataSources={{
    primary: {
      data: {
        fields: [
          {
            name: 'Name'
          },
          {
            name: 'UserID'
          },
          {
            name: 'Money Spent'
          },
          {
            name: 'Most Recent Game'
          }
        ],
        columns: [
          [
            'Ms. Herman Beer',
            'Crystal Ziemann',
            'Phil Bartoletti',
            'Janis Kiehn V',
            'Angel Krajcik',
            'Patti Hodkiewicz IV',
            'Joanne Emmerich',
            'Jay Renner',
            'Ora Borer',
            'Dr. Bradford Gulgowski'
          ],
          [
            'Enrico98',
            'Taylor_Parker83',
            'Candice_Carroll',
            'Yolanda_McLaughlin95',
            'Modesto84',
            'Elwin52',
            'Francis8',
            'Charley.Feeney85',
            'Jensen_Jacobson74',
            'Dora_Volkman'
          ],
          [
            9740890.83,
            2107983.52,
            5467223.67,
            9529184.93,
            9692275.78,
            5692737.43,
            1001734.82,
            3848531.8,
            3848531.8
          ],
          [
            '2020-04-12T06:32:08-07:00',
            '2020-06-06T16:14:04-07:00',
            '2020-02-12T09:43:25-08:00',
            '2020-07-25T13:19:49-07:00',
            '2020-03-16T21:46:40-07:00',
            '2020-08-21T08:38:55-07:00',
            '2020-09-26T16:06:03-07:00',
            '2020-08-10T14:54:16-07:00',
            '2020-08-11T16:49:24-07:00',
            '2020-09-29T03:52:51-07:00'
          ]
        ]
      },
      meta: {
        totalCount: 100
      },
      requestParams: {
        count: 10,
        offset: 0
      }
    }
  }}
/>

Select a DataSeries by specifying the index of the series you want to return.
@public
@param {number} index
@returns {DataSeries<DataType>}

The following code sample shows how to use seriesByIndex to display the second series in a data source as a single value.
```

## Example 2

```jsx
<Table
  options={{
    table: '> primary | frameBySeriesIndexRange(0,2)'
  }},
  dataSources={{
    primary: {
      data: {
        fields: [
          {
            name: 'Name'
          },
          {
            name: 'UserID'
          },
          {
            name: 'Money Spent'
          },
          {
            name: 'Most Recent Game'
          },
        ],
        columns: [
          [
            'Ms. Herman Beer',
            'Crystal Ziemann',
            'Phil Bartoletti',
            'Janis Kiehn V',
            'Angel Krajcik',
            'Patti Hodkiewicz IV',
            'Joanne Emmerich',
            'Jay Renner',
            'Ora Borer',
            'Dr. Bradford Gulgowski'
          ],
          [
            'Enrico98',
            'Taylor_Parker83',
            'Candice_Carroll',
            'Yolanda_McLaughlin95',
            'Modesto84',
            'Elwin52',
            'Francis8',
            'Charley.Feeney85',
            'Jensen_Jacobson74',
            'Dora_Volkman'
          ],
          [
            9740890.83,
            2107983.52,
            5467223.67,
            9529184.93,
            9692275.78,
            9395814.7,
            5692737.43,
            1001734.82,
            3848531.8,
            1691776.38
          ],
          [
            '2020-04-12T06:32:08-07:00',
            '2020-06-06T16:14:04-07:00',
            '2020-02-12T09:43:25-08:00',
            '2020-07-25T13:19:49-07:00',
            '2020-03-16T21:46:40-07:00',
            '2020-08-21T08:38:55-07:00',
            '2020-09-26T16:06:03-07:00',
            '2020-08-10T14:54:16-07:00',
            '2020-08-11T16:49:24-07:00',
            '2020-09-29T03:52:51-07:00'
          ]
        ]
      },
      meta: {
        totalCount: 100
      },
      requestParams: {
        count: 10,
        offset: 0
      }
    }
  }}
/>

Filter a DataFrame by specifying the names of the DataSeries you would like to return.
For example, `frameBySeriesNames(first_name, second_name, ...)`, where at least one series name is required.
@public
@param {string[]} names
@returns {DataFrame<DataType>}

The following code sample shows how to use frameBySeriesNames to render a table with the Name and Money Spent columns in the data source.
```

## Example 3

```jsx
<Table
    options={{
        table: '> primary | frameWithoutInternalFields()'
    }},
    dataSources={{
        primary: {
            data: {
                fields: [
                    {
                        name: 'Name'
                    },
                    {
                        name: 'UserID'
                    },
                    {
                        name: '_time'
                    },
                    {
                        name: '_span'
                    },
                ],
                columns: [
                    [
                        'Ms. Herman Beer',
                        'Crystal Ziemann',
                        'Jay Renner',
                        'Ora Borer',
                        'Dr. Bradford Gulgowski'
                    ],
                    [
                        'Enrico98',
                        'Taylor_Parker83',
                        'Charley.Feeney85',
                        'Jensen_Jacobson74',
                        'Dora_Volkman'
                    ],
                    [
                        '2020-04-12T06:32:08-07:00',
                        '2020-06-06T16:14:04-07:00',
                        '2020-08-10T14:54:16-07:00',
                        '2020-08-11T16:49:24-07:00',
                        '2020-09-29T03:52:51-07:00'
                    ],
                    [
                        '1800',
                        '1800',
                        '1800',
                        '1800',
                        '1800'
                    ]
                ]
            },
            meta: {
                totalCount: 100
            },
            requestParams: {
                count: 10,
                offset: 0
            }
        }
    }}
/>
```

## Example 4

```jsx
<SingleValue
    options={{
        "majorValue": "> primary | frameWithoutInternalFields() | seriesByIndex(0) | lastPoint()"
    }},
    dataSources={{
        primary: {
            data: {
                fields: [
                    {
                        name: '_time'
                    },
                    {
                        name: '_span'
                    },
                    {
                        name: 'Name'
                    },
                    {
                        name: 'UserID'
                    }
                ],
                columns: [
                    [
                        '2020-04-12T06:32:08-07:00',
                        '2020-06-06T16:14:04-07:00',
                        '2020-08-10T14:54:16-07:00',
                        '2020-08-11T16:49:24-07:00',
                        '2020-09-29T03:52:51-07:00'
                    ],
                    [
                        '1800',
                        '1800',
                        '1800',
                        '1800',
                        '1800'
                    ],
                    [
                        'Patti Hodkiewicz IV',
                        'Joanne Emmerich',
                        'Jay Renner',
                        'Ora Borer',
                        'Dr. Bradford Gulgowski'
                    ],
                    [
                        'Elwin52',
                        'Francis8',
                        'Charley.Feeney85',
                        'Jensen_Jacobson74',
                        'Dora_Volkman'
                    ]
                ]
            },
            meta: {
                totalCount: 100
            },
            requestParams: {
                count: 10,
                offset: 0
            }
        }
    }}
/>
```

## Example 5

```jsx
<Table
    options={{
        table: "> primary | frameWithoutInternalFieldsExcept('_time', '_span')"
    }},
    dataSources={{
        primary: {
            data: {
                fields: [
                    {
                        name: 'Name'
                    },
                    {
                        name: 'UserID'
                    },
                    {
                        name: '_time'
                    },
                    {
                        name: '_span'
                    },
                    {
                        name: '_raw'
                    },
                ],
                columns: [
                    [
                        'Ms. Herman Beer',
                        'Joanne Emmerich',
                        'Jay Renner',
                        'Ora Borer',
                        'Dr. Bradford Gulgowski'
                    ],
                    [
                        'Enrico98',
                        'Francis8',
                        'Charley.Feeney85',
                        'Jensen_Jacobson74',
                        'Dora_Volkman'
                    ],
                    [
                        '2020-04-12T06:32:08-07:00',
                        '2020-09-26T16:06:03-07:00',
                        '2020-08-10T14:54:16-07:00',
                        '2020-08-11T16:49:24-07:00',
                        '2020-09-29T03:52:51-07:00'
                    ],
                    [
                        '1800',
                        '1800',
                        '1800',
                        '1800',
                        '1800'
                    ],
                    [
                        '2020-04-12T06:32:08-07:00',
                        '2020-09-26T16:06:03-07:00',
                        '2020-08-10T14:54:16-07:00',
                        '2020-08-11T16:49:24-07:00',
                        '2020-09-29T03:52:51-07:00'
                    ]
                ]
            },
            meta: {
                totalCount: 100
            },
            requestParams: {
                count: 10,
                offset: 0
            }
        }
    }}
/>
```

## Example 6

```jsx
<SingleValue
    options={{
        "majorValue": "> primary | frameWithoutInternalFieldsExcept('_time') | seriesByIndex(1) | lastPoint()"
    }},
    dataSources={{
        primary: {
            data: {
                fields: [
                    {
                        name: '_time'
                    },
                    {
                        name: '_span'
                    },
                    {
                        name: '_raw'
                    },
                    {
                        name: 'Name'
                    },
                    {
                        name: 'UserID'
                    }
                ],
                columns: [
                    [
                        '2020-04-12T06:32:08-07:00',
                        '2020-09-26T16:06:03-07:00',
                        '2020-08-10T14:54:16-07:00',
                        '2020-08-11T16:49:24-07:00',
                        '2020-09-29T03:52:51-07:00'
                    ],
                    [
                        '1800',
                        '1800',
                        '1800',
                        '1800',
                        '1800'
                    ],
                    [
                        '2020-04-12T06:32:08-07:00',
                        '2020-06-06T16:14:04-07:00',
                        '2020-08-10T14:54:16-07:00',
                        '2020-08-11T16:49:24-07:00',
                        '2020-09-29T03:52:51-07:00'
                    ],
                    [
                        'Ms. Herman Beer',
                        'Crystal Ziemann',
                        'Angel Krajcik',
                        'Jay Renner',
                        'Dr. Bradford Gulgowski'
                    ],
                    [
                        'Candice_Carroll',
                        'Elwin52',
                        'Francis8',
                        'Charley.Feeney85',
                        'Dora_Volkman'
                    ]
                ]
            },
            meta: {
                totalCount: 100
            },
            requestParams: {
                count: 10,
                offset: 0
            }
        }
    }}
/>
```

## Example 7

```jsx
<Table
    options={{
        table: '> primary | frameBySeriesNamesOrIndexes("Name", 3)'
    }},
    dataSources={{
        primary: {
            data: {
                fields: [
                    {
                        name: 'Name'
                    },
                    {
                        name: 'UserID'
                    },
                    {
                        name: 'Money Spent'
                    },
                    {
                        name: 'Most Recent Game'
                    },
                ],
                columns: [
                    [
                        'Ms. Herman Beer',
                        'Crystal Ziemann',
                        'Phil Bartoletti',
                        'Janis Kiehn V',
                        'Angel Krajcik',
                        'Patti Hodkiewicz IV',
                        'Joanne Emmerich',
                        'Jay Renner',
                        'Ora Borer',
                        'Dr. Bradford Gulgowski'
                    ],
                    [
                        'Enrico98',
                        'Taylor_Parker83',
                        'Candice_Carroll',
                        'Yolanda_McLaughlin95',
                        'Modesto84',
                        'Elwin52',
                        'Francis8',
                        'Charley.Feeney85',
                        'Jensen_Jacobson74',
                        'Dora_Volkman'
                    ],
                    [
                        9740890.83,
                        2107983.52,
                        5467223.67,
                        9529184.93,
                        9692275.78,
                        9395814.7,
                        5692737.43,
                        1001734.82,
                        3848531.8,
                        1691776.38
                    ],
                    [
                        '2020-04-12T06:32:08-07:00',
                        '2020-06-06T16:14:04-07:00',
                        '2020-02-12T09:43:25-08:00',
                        '2020-07-25T13:19:49-07:00',
                        '2020-03-16T21:46:40-07:00',
                        '2020-08-21T08:38:55-07:00',
                        '2020-09-26T16:06:03-07:00',
                        '2020-08-10T14:54:16-07:00',
                        '2020-08-11T16:49:24-07:00',
                        '2020-09-29T03:52:51-07:00',
                    ]
                ]
            },
            meta: {
                totalCount: 100
            },
            requestParams: {
                count: 10,
                offset: 0
            }
        }
    }}
/>
```

## Example 8

```jsx
<Table
    options={{
        table: '> primary | frameBySeriesTypes("string")'
    }},
    dataSources={{
        primary: {
            data: {
                fields: [
                    {
                        name: 'Name'
                    },
                    {
                        name: 'UserID'
                    },
                    {
                        name: 'Money Spent'
                    },
                    {
                        name: 'Most Recent Game'
                    },
                ],
                columns: [
                    [
                        'Ms. Herman Beer',
                        'Crystal Ziemann',
                        'Phil Bartoletti',
                        'Janis Kiehn V',
                        'Angel Krajcik',
                        'Patti Hodkiewicz IV',
                        'Joanne Emmerich',
                        'Jay Renner',
                        'Ora Borer',
                        'Dr. Bradford Gulgowski'
                    ],
                    [
                        'Enrico98',
                        'Taylor_Parker83',
                        'Candice_Carroll',
                        'Yolanda_McLaughlin95',
                        'Modesto84',
                        'Elwin52',
                        'Francis8',
                        'Charley.Feeney85',
                        'Jensen_Jacobson74',
                        'Dora_Volkman'
                    ],
                    [
                        9740890.83,
                        2107983.52,
                        5467223.67,
                        9529184.93,
                        9692275.78,
                        9395814.7,
                        5692737.43,
                        1001734.82,
                        3848531.8,
                        1691776.38
                    ],
                    [
                        '2020-04-12T06:32:08-07:00',
                        '2020-06-06T16:14:04-07:00',
                        '2020-02-12T09:43:25-08:00',
                        '2020-07-25T13:19:49-07:00',
                        '2020-03-16T21:46:40-07:00',
                        '2020-08-21T08:38:55-07:00',
                        '2020-09-26T16:06:03-07:00',
                        '2020-08-10T14:54:16-07:00',
                        '2020-08-11T16:49:24-07:00',
                        '2020-09-29T03:52:51-07:00'
                    ]
                ]
            },
            meta: {
                totalCount: 100
            },
            requestParams: {
                count: 10,
                offset: 0
            }
        }
    }}
/>

Select a DataSeries by specifying the name of the DataSeries you would like to return.
@public
@param {string} field
@returns {DataSeries<DataType>}

The following code sample shows how to use seriesByName to display the count series in a data source as a single value.
```

## Example 9

```jsx
<SingleValue
    options={{
        sparklineValues: '> primary | seriesByType("number")',
    }}
    dataSources={{
        primary: {
            data: {
                fields: [
                    {
                        name: '_time',
                    },
                    {
                        name: 'count',
                    },
                ],
                columns: [
                    [
                        '2018-08-19T00:00:00.000+00:00',
                        '2018-08-20T00:00:00.000+00:00',
                        '2018-08-21T00:00:00.000+00:00',
                        '2018-08-22T00:00:00.000+00:00',
                        '2018-08-23T00:00:00.000+00:00',
                        '2018-08-24T00:00:00.000+00:00',
                        '2018-08-25T00:00:00.000+00:00',
                        '2018-08-26T00:00:00.000+00:00',
                    ],
                    [ '1', '62', '103', '308', '587', '876', '930', '1320'],
                ],
            },
            meta: {},
        },
    }}
/>

Select a DataSeries by specifying any acceptable types of the DataSeries you would like to return. The first DataSeries that matches any of the types specified will be returned. If no DataSeries matches the type options specified, no DataSeries will be returned.
@public
@param {DataType[]} types
@returns {DataSeries<DataType>}

Select a DataSeries by specifying the prioritized types of the DataSeries you would like to return. The first DataSeries that matches the first type specified will be returned. If no DataSeries matches the first type specified, the first DataSeries that matches the second type will be returned, and so on.
@public
@param {DataType[]} types
@returns {DataSeries<DataType>}

The following code sample shows how to use seriesByPrioritizedTypes to display the first numeric series in a data source as a single value.

If no numeric series are found in the data, the first series of type string is displayed. If no string series are found, the first series of type time is displayed.
```

## Example 10

```jsx
<Table
  options={{
      headers: '> table | getField()'
  }},
  dataSources={{
    primary: {
      data: {
        fields: [
          {
             name: 'Name'
          },
          {
             name: 'UserID'
          },
          {
             name: 'Money Spent'
          },
          {
             name: 'Most Recent Game'
          },
        ],
        columns: [
          [
             'Ms. Herman Beer',
             'Crystal Ziemann',
             'Phil Bartoletti',
             'Janis Kiehn V',
             'Angel Krajcik',
             'Patti Hodkiewicz IV',
             'Joanne Emmerich',
             'Jay Renner',
             'Ora Borer',
             'Dr. Bradford Gulgowski'
          ],
          [
             'Enrico98',
             'Taylor_Parker83',
             'Candice_Carroll',
             'Yolanda_McLaughlin95',
             'Modesto84',
             'Elwin52',
             'Francis8',
             'Charley.Feeney85',
             'Jensen_Jacobson74',
             'Dore_Volkman'
          ],
          [
             9740890.83,
             2107983.52,
             5467223.67,
             9529184.93,
             9692275.78,
             9395814.7,
             5692737.43,
             1001734.82,
             3848531.8,
             1691776.38
          ],
          [
             '2020-04-12T06:32:08-07:00',
             '2020-06-06T16:14:04-07:00',
             '2020-02-12T09:43:25-08:00',
             '2020-07-25T13:19:49-07:00',
             '2020-03-16T21:46:40-07:00',
             '2020-08-21T08:38:55-07:00',
             '2020-09-26T16:06:03-07:00',
             '2020-08-10T14:54:16-07:00',
             '2020-08-11T16:49:24-07:00',
             '2020-09-29T03:52:51-07:00'
          ]
        ]
     },
     meta: {
       totalCount: 100
     },
     requestParams: {
       count: 10,
       offset: 0
     }
    }
  }}
/>

Display the third and fourth DataSeries in a column chart as overlay fields.

<Column
  options={{
    overlayFields: '> primary | frameBySeriesIndex(2,3) | getField()'
  }},
  dataSources={{
    primary: {
      requestParams: { offset: 0, count: 20},
      data: {
        fields: [
            { name: '_time' },
            { name: 'splunkd' },
            { name: 'splunkd_web_access' },
            { name: 'mongod' },
        ],
        columns: [
            [
                '2018-05-02T18:15:46.000-07:00',
                '2018-05-02T18:15:47.000-07:00',
                '2018-05-02T18:15:48.000-07:00',
                '2018-05-02T18:15:49.000-07:00',
                '2018-05-02T18:15:50.000-07:00',
            ],
            ['67228', '83195', '3145', '19332', '29763'],
            ['67228', '83195', '3145', '19332', '29763'],
            ['14881', '17341', '18081', '19774', '10467'],
        ]
      },
      meta: {
        totalCount: 100,
      }
    }
  }}
/>

Get the data type of each DataSeries in the DataFrame.
@public
@returns {string[]}

Get the global minimum value from all numeric DataSeries in the DataFrame.
@public
@returns {number}

The following code sample shows how to use min to display the smallest data point in a data source as a single value.
```

## Example 11

```jsx
<SingleValue
    options={{
        majorValue: '> primary | max()',
        trendDisplay: 'off',
        sparklineDisplay: 'off',
    }}
    dataSources={{
        primary: {
            data: {
                fields: [
                    {
                        name: '_time',
                    },
                    {
                        name: 'count',
                    },
                ],
                columns: [
                    [
                        '2018-08-19T00:00:00.000+00:00',
                        '2018-08-20T00:00:00.000+00:00',
                        '2018-08-21T00:00:00.000+00:00',
                        '2018-08-22T00:00:00.000+00:00',
                        '2018-08-23T00:00:00.000+00:00',
                        '2018-08-24T00:00:00.000+00:00',
                        '2018-08-25T00:00:00.000+00:00',
                        '2018-08-26T00:00:00.000+00:00',
                    ],
                    [ '1', '62', '103', '308', '587', '876', '930', '1320' ],
                ],
            },
            meta: {},
        },
    }}
/>

Get the count of all values from all DataSeries in the DataFrame.
@public
@returns {DataPoint<DataType>}

The following code sample shows how to use count to display the total number of data points in a data source as a single value.
```

## Example 12

```jsx
Get the nearest-rank percentile of all numeric values from all numeric DataSeries in the DataFrame.
@public
@param {number} percentile value from 0 to 100
@returns {DataPoint<DataType>}

The following code sample shows how to use percentile to display the 90th percentile of all data points in a data source as a single value.
```

## Example 13

```jsx
Get the average of all numeric values from all numeric DataSeries in the DataFrame.
@public
@returns {DataPoint<DataType>}

The following code sample shows how to use average to display the mean of all data points in a data source as a single value.
```

## Example 14

```jsx
Get the sum of all numeric values from all numeric DataSeries in the DataFrame.
@public
@returns {DataPoint<DataType>}

The following code sample shows how to use sum to display the total of all data points in a data source as a single value.
```

## Example 15

```jsx
runs result of min or max function over all the series and returns the data point
points
@param {string} aggName
@returns {DataPoint<T>}
```
