ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Transpose Fields

  • Summary
  • Illustration
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Shifts data entered in fields or columns into rows in a table or feature class.

This tool is useful when your table or feature class stores values in field names (such as Field1, Field2, Field3) and you want to transpose the field names and the corresponding data values in the fields into a row format.

Illustration

Transpose time fields illustration
In the illustration, Field1, Field2, and Field3 of the Input table are transposed and stored in the Transposed Output table. Here, the value of each transposed field is stored in the Value field. Additional attribute fields Shape and Type are stored in the output.

Usage

  • By default, the output is a table. However, if you want to transpose the fields in a feature class, you can choose to output either a table or a feature class with the transposed fields. To output a feature class, you should choose the Shape field under Attribute Fields.

  • If the feature class is an input, the only way you can get a feature class output is to select the Shape field in the Attribute Fields parameter.

Syntax

TransposeFields_management (in_table, in_field, out_table, in_transposed_field_name, in_value_field_name, {attribute_fields})
ParameterExplanationData Type
in_table

The input feature class or table for which the fields containing data values will be transposed.

Table View
in_field
[[field, {value}],...]

The fields or columns containing data values in the input table that need to be transposed.

Depending on your needs, you can select multiple fields that need to be transposed. By default, the value is the same as the field name. However, you can choose to specify your own value. For example, if the field names of the fields you want to transpose are Pop1991, Pop1992, and so on, by default, the values for these field will be the same ( Pop1991, Pop1992, and so forth). However, you can choose to specify your own values such as 1991 and 1992.

Value Table
out_table

The output feature class or table. The output feature class or table will contain the transposed field, a value field, and any number of attribute fields specified that need to be inherited from the input table.

What is specified for out_table will be a table, unless the in_table value is a feature class and the Shape field is selected in the attribute_fields parameter.

Table
in_transposed_field_name

The name of the field that will be created to store field name values of the fields that are selected to be transposed. Any valid field name can be used.

String
in_value_field_name

The name of the value field that will be created to store the values from the input table. Any valid field name can be set, as long as it does not conflict with existing field names from the input table or feature class.

String
attribute_fields
[attribute_fields,...]
(Optional)

Attribute fields from the input table to be included in the output table. If you want to output a feature class, choose the Shape field.

Field

Code sample

TransposeFields example (Python window)

The following Python window script demonstrates how to use the TransposeFields tool in immediate mode.

import arcpy
arcpy.TransposeFields_management("C:/Data/TemporalData.gdb/Input","Field1 newField1;Field2 newField2;Field3 newField3",
                                 "C:/Data/TemporalData.gdb/Output_Time","Transposed_Field", "Value","Shape;Type")
TransposeFields example 2 (stand-alone script)

The following stand-alone script demonstrates how to use the TransposeFields tool.

# Name: TransposeFields_Ex_02.py
# Description: Tranpose field names from column headers to values in one column
# Requirements: None

# Import system modules
import arcpy
from arcpy import env

# set workspace
arcpy.env.workspace = "C:/Data/TemporalData.gdb"

# Set local variables
inTable = "Input"
# Specify fields to transpose
fieldsToTranspose = "Field1 newField1;Field2 newField2;Field3 newField3"
# Set a variable to store output feature class or table
outTable = "Output_Time"
# Set a variable to store time field name
transposedFieldName = "Transposed_Field"
# Set a variable to store value field name
valueFieldName = "Value"
# Specify attribute fields to be included in the output
attrFields = "Shape;Type"

# Execute TransposeTimeFields
arcpy.TransposeFields_management(inTable, fieldsToTranspose, outTable, transposedFieldName, valueFieldName, attrFields)

Environments

This tool does not use any geoprocessing environments

Licensing information

  • ArcGIS for Desktop Basic: Yes
  • ArcGIS for Desktop Standard: Yes
  • ArcGIS for Desktop Advanced: Yes

Related topics

  • An overview of the Fields toolset

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal