Field Statistics To Table (Data Management)

Summary

Creates a table of descriptive statistics for one or more input fields in a table or feature class.

Illustration

Field Statistics To Table tool illustration

Usage

  • The tool accepts a feature class or stand-alone table as input.

  • For the Input Fields parameter, multiple fields can be specified for which statistics can be calculated. The parameter accepts numeric (Short, Long, Float, and Double types), Text, and Date type fields.

  • The order of the fields specified by the Input Fields parameter will be the order of the rows in the output table.

  • The Group By Field parameter is used to calculate input field statistics separately for each unique value in the specified field. The statistics for each of the input fields will be calculated and reported once per unique value in the group by field.

  • The Output Tables parameter has four options for the Field Types column:

    • All—All of the input fields and output statistics, regardless of the field type, will be exported to a single output table.
    • Numeric—Only the Numeric type input fields (Short, Long, Float, and Double) will be exported, and only the statistics applicable to Numeric field types will be exported to the output table.
    • Text—Only the Text type input fields will be exported, and only the statistics applicable to the Text field type will be exported to the output table.
    • Date—Only the Date type input fields will be exported, and only the statistics applicable to the Date field type will be exported to the output table.

    For each output table, the name of the table is specified in the Output Name column of the Output Tables parameter, and the table will be saved in the workspace specified by the Output Location parameter.

  • The output statistics and their field names can be configured using the Output Statistics parameter. If no value is provided for this parameter, all of the applicable output statistics will be included in the output tables. The following table lists the available statistics and the corresponding output field type for each option of the Field Types column of the Output Tables parameter:

    Output statisticAllNumericTextDate

    Field Name

    Text

    Text

    Text

    Text

    Alias

    Text

    Text

    Text

    Text

    Field type

    Text

    Text

    Text

    Text

    Nulls

    Long

    Long

    Long

    Long

    Minimum

    Text

    Double

    -

    Date

    Maximum

    Text

    Double

    -

    Date

    Mean

    Text

    Double

    -

    Date

    Standard deviation

    Double

    Double

    -

    -

    Median

    Text

    Double

    -

    Date

    Count

    Long

    Long

    Long

    Long

    Number of unique values

    Long

    Long

    Long

    Long

    Mode

    Text

    Double

    Text

    Date

    Least common

    Text

    Double

    Text

    Date

    Outliers

    Long

    Long

    -

    -

    Sum

    Double

    Double

    -

    -

    Range

    Text

    Double

    -

    -

    Interquartile range

    Double

    Double

    -

    -

    First quartile

    Text

    Double

    -

    Date

    Third quartile

    Text

    Double

    -

    Date

    Coefficient of variation

    Double

    Double

    -

    -

    Skewness

    Double

    Double

    -

    -

    Kurtosis

    Double

    Double

    -

    -

    The available statistics and the corresponding output field types for each type of output table are listed.
  • The available statistics are the same as those available in the Data Engineering view. For details on how each statistic is calculated, see Interact with statistics.

  • If you choose All for the Field Types column of the Output Tables parameter, all the field types will be exported in a single table. This can help you visualize all the input fields and their statistics at once. This provides advantages for certain applications; for example, it might be preferred when using the statistics in a layout or a report. However, there are caveats to exporting different field types as a single table. Some statistic options that are common across field types, including Mode, Least Common, Minimum, and Maximum, will be stored as text fields in the output table. This can cause problems, for example, when sorting these values in the statistics columns or chaining the output statistics in a model. There will also be empty cells in the table, as certain statistics do not apply to text or date fields.

  • If you choose Numeric, Text, or Date for the Field Types column of the Output Tables parameter, each field type will be exported in a separate table, and the output tables will only include the statistics applicable to that field type. Some statistics that apply to multiple field types will be stored in the format matching the input field type. For example, in the Numeric table, the Minimum field will be of type Double, and it will be of type Date in the Date table. It is recommended that you have different output tables. For example, to save the statistics as the same type as the input fields, sort the statistics in the output table or further use their values in a model.

  • The Mode and Least Common statistic options can correspond to multiple values in an input field in the case of a tie. In such cases, multiple values will be reported as <Null> for Numeric, Text, and Date output tables. For the All option, the output cell will contain the text Multiple Values.

Parameters

LabelExplanationData Type
Input Table

The input table containing the fields that will be used to create the statistics table.

Table View
Input Fields

The fields containing the values that will be used to calculate the statistics.

Field
Output Location

The location where the output tables will be created. The location can be a geodatabase, folder, or feature dataset.

Workspace
Output Tables

The output tables containing the statistics. The Field Types column specifies the field types that will be included in each output table, and the name of each output table is provided in the Output Name column. For example, you can create a single table with summaries of all field types, or you can create separate tables for summaries of Numeric, Text, and Date field types.

The following choices are available for the Field Types column:

  • Numeric—A table summarizing numeric fields of the input (Short, Long, Float, and Double types) will be created.
  • Text—A table summarizing text fields of the input (Text type) will be created.
  • Date—A table summarizing date fields of the input (Date type) will be created.
  • All—A table summarizing all numeric, text, and date fields of the input will be created. Output fields containing statistics that apply to multiple field types will be saved as type Text. Output statistics that do not apply to Text and Date type fields will be empty.

Value Table
Group By Field
(Optional)

The field that will be used to group rows into categories. If a group by field is provided, each field of the input will appear as a row in the output table once per unique value in the group by field.

Field
Output Statistics
(Optional)

Specifies the statistics that will be summarized and the names of the output fields containing the statistics. The statistic is provided in the Statistic column, and the name of the output field is provided in the Output Field Name column. If no values are provided, all applicable statistics will be calculated for all input fields.

The following choices are available for the Statistic column (only statistics applicable to the input fields will be available):

  • Field name—The name of the field.
  • Alias—The alias of the field.
  • Field type—The field type of the field (Short, Long, Double, Float, Text, or Date).
  • Nulls—The number of records containing null values of the field.
  • Minimum—The smallest value in the field.
  • Maximum—The largest value in the field.
  • Mean—The mean (sum divided by total count) of all values in the field. To calculate the mean date for date fields, each date is converted to a number by calculating the difference between the date and a reference date (for example, 1900-01-01), calculated in milliseconds.
  • Standard deviation—The standard deviation of the values in the field. It is calculated as the square root of the variance, in which the variance is the average squared difference of each value from the mean of the field.
  • Median—The median for all values in the field. The median is the middle value in the sorted list of values. If there is an even number of values, the median is the mean of the two middle values in the distribution.
  • Count—The number of nonnull values in the field.
  • Number of unique values—The number of unique values in the field.
  • Mode—The most frequently occurring value in the field.
  • Least common—The least common value in the field.
  • Outliers—The number of records with outlier values in the field. Outliers are values that are more than 1.5 times the interquartile range above the third quartile or below the first quartile of the values of the field.
  • Sum—The sum of all values in the field.
  • Range—The difference between the largest and smallest values in the field.
  • Interquartile range—The range between the first quartile and the third quartile of the values in the field. This represents the range of the middle half of the data.
  • First quartile—The value of the first quartile of the field. Quartiles divide the sorted list of values into four groups containing equal numbers of values. The first quartile is the upper limit of the first group in ascending order.
  • Third quartile—The value of the third quartile of the field. Quartiles divide the sorted list of values into four groups containing equal numbers of values. The third quartile is the upper limit of the third group in ascending order.
  • Coefficient of variation—The coefficient of variation of the values in the field. The coefficient of variation is a measure of the relative spread of the values. It is calculated as the standard deviation divided by the mean of the field.
  • Skewness—The skewness of the values in the field. Skewness measures the symmetry of the distribution. The skewness is calculated as the third moment (the average of the cubed data values) divided by the cubed standard deviation.
  • Kurtosis—The kurtosis of the values in the field. Kurtosis describes the heaviness of the tails of a distribution compared to the normal distribution, helping identify the frequency of extreme values. The kurtosis is calculated as the fourth moment (the average of the data values taken to the fourth power) divided by the fourth power of the standard deviation.

Value Table

Derived Output

LabelExplanationData Type
Output Table for Numeric Fields

The output tables for Numeric data types. The table will be saved in the workspace specified in the Output Location parameter.

Table
Output Table for Text Fields

The output tables for Text data types. The table will be saved in the workspace specified in the Output Location parameter.

Table
Output Table for Date Fields

The output tables for Date data types. The table will be saved in the workspace specified in the Output Location parameter.

Table
Output Table for All Fields

The output tables for all data types. The table will be saved in the workspace specified in the Output Location parameter.

Table

arcpy.management.FieldStatisticsToTable(in_table, in_fields, out_location, out_tables, {group_by_field}, {out_statistics})
NameExplanationData Type
in_table

The input table containing the fields that will be used to create the statistics table.

Table View
in_fields
[in_fields,...]

The fields containing the values that will be used to calculate the statistics.

Field
out_location

The location where the output tables will be created. The location can be a geodatabase, folder, or feature dataset.

Workspace
out_tables
[[field_type, output_name],...]

The output tables containing the statistics. The field_type column specifies the field types that will be included in each output table, and the name of each output table is provided in the output_name column. For example, you can create a single table with summaries of all field types, or you can create separate tables for summaries of Numeric, Text, and Date field types.

The following choices are available for the field_type column:

  • NUMERIC—A table summarizing numeric fields of the input (Short, Long, Float, and Double types) will be created.
  • TEXT—A table summarizing text fields of the input (Text type) will be created.
  • DATE—A table summarizing date fields of the input (Date type) will be created.
  • ALL—A table summarizing all numeric, text, and date fields of the input will be created. Output fields containing statistics that apply to multiple field types will be saved as type Text. Output statistics that do not apply to Text and Date type fields will be empty.

Value Table
group_by_field
(Optional)

The field that will be used to group rows into categories. If a group by field is provided, each field of the input will appear as a row in the output table once per unique value in the group by field.

Field
out_statistics
[[out_statistic, output_name],...]
(Optional)

Specifies the statistics that will be summarized and the names of the output fields containing the statistics. The statistic is provided in the out_statistic column, and the name of the output field is provided in the output_name column. If no values are provided, all applicable statistics will be calculated for all input fields.

The following choices are available for the out_statistic column (only statistics applicable to the input fields will be available):

  • FIELDNAME—The name of the field.
  • ALIAS—The alias of the field.
  • FIELDTYPE—The field type of the field (Short, Long, Double, Float, Text, or Date).
  • NULLS—The number of records containing null values of the field.
  • MINIMUM—The smallest value in the field.
  • MAXIMUM—The largest value in the field.
  • MEAN—The mean (sum divided by total count) of all values in the field. To calculate the mean date for date fields, each date is converted to a number by calculating the difference between the date and a reference date (for example, 1900-01-01), calculated in milliseconds.
  • STANDARDDEVIATION—The standard deviation of the values in the field. It is calculated as the square root of the variance, in which the variance is the average squared difference of each value from the mean of the field.
  • MEDIAN—The median for all values in the field. The median is the middle value in the sorted list of values. If there is an even number of values, the median is the mean of the two middle values in the distribution.
  • COUNT—The number of nonnull values in the field.
  • NUMBEROFUNIQUEVALUES—The number of unique values in the field.
  • MODE—The most frequently occurring value in the field.
  • LEASTCOMMON—The least common value in the field.
  • OUTLIERS—The number of records with outlier values in the field. Outliers are values that are more than 1.5 times the interquartile range above the third quartile or below the first quartile of the values of the field.
  • SUM—The sum of all values in the field.
  • RANGE—The difference between the largest and smallest values in the field.
  • INTERQUARTILERANGE—The range between the first quartile and the third quartile of the values in the field. This represents the range of the middle half of the data.
  • FIRSTQUARTILE—The value of the first quartile of the field. Quartiles divide the sorted list of values into four groups containing equal numbers of values. The first quartile is the upper limit of the first group in ascending order.
  • THIRDQUARTILE—The value of the third quartile of the field. Quartiles divide the sorted list of values into four groups containing equal numbers of values. The third quartile is the upper limit of the third group in ascending order.
  • COEFFICIENTOFVARIATION—The coefficient of variation of the values in the field. The coefficient of variation is a measure of the relative spread of the values. It is calculated as the standard deviation divided by the mean of the field.
  • SKEWNESS—The skewness of the values in the field. Skewness measures the symmetry of the distribution. The skewness is calculated as the third moment (the average of the cubed data values) divided by the cubed standard deviation.
  • KURTOSIS—The kurtosis of the values in the field. Kurtosis describes the heaviness of the tails of a distribution compared to the normal distribution, helping identify the frequency of extreme values. The kurtosis is calculated as the fourth moment (the average of the data values taken to the fourth power) divided by the fourth power of the standard deviation.

Value Table

Derived Output

NameExplanationData Type
out_numeric

The output tables for Numeric data types. The table will be saved in the workspace specified in the Output Location parameter.

Table
out_text

The output tables for Text data types. The table will be saved in the workspace specified in the Output Location parameter.

Table
out_date

The output tables for Date data types. The table will be saved in the workspace specified in the Output Location parameter.

Table
out_all

The output tables for all data types. The table will be saved in the workspace specified in the Output Location parameter.

Table

Code sample

FieldStatisticsToTable example 1 (Python window)

The following Python window script demonstrates how to use the FieldStatisticsToTable function.

import arcpy
arcpy.management.FieldStatisticsToTable("SNAP_County_Rates", 
      "LocId;Program_Name;Participants;SNAP_Rate;TimeofYear", r"C:\Output.gdb", 
      "ALL All_Table;DATE Date_Table;NUMERIC Num_Table;TEXT Text_Table")
FieldStatisticsToTable example 2 (stand-alone script)

The following stand-alone Python script demonstrates how to use the FieldStatisticsToTable function.

# Import system modules.
import arcpy

try:
    # Set the workspace and input features. 
    arcpy.env.workspace = r"C:\\Statistics\\MyData.gdb" 
    in_table = "County_Data" 
 
    # Set the input fields that will be used to calculate statistics. 
    in_fields = "population_total;unemployment_rate;income;county_name;sample_date" 
 
    # Set the output location.
    out_location = r"C:\\Statistics\\MyData.gdb"

    # Set the output table field type and name.
    out_tables = "ALL AllStats_Table;DATE DateStats_Table;NUMERIC NumStats_Table;TEXT TextStats_Table"
 
    # Run the Field Statistics To Table tool 
    arcpy.management.FieldStatisticsToTable (in_table, in_fields, out_location, out_tables) 
 
except arcpy.ExecuteError: 
    # If an error occurred when running the tool, print the error message. 
    print(arcpy.GetMessages())

Environments

This tool does not use any geoprocessing environments.

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics