フィールドの転置(Transpose Fields) (データの管理)
サマリ
フィールドまたは列に入力されたデータを、テーブルまたはフィーチャクラスの行にシフトします。
このツールは、テーブルまたはフィーチャクラスのフィールド名(Field1、Field2、Field3)に値が含まれており、フィールド名とその対応するデータ値を行形式のフィールドに転置したい場合に便利です。
図
![]() |
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. |
使用法
-
デフォルトでは、出力はテーブルです。ただし、フィールドをフィーチャクラスに転置したい場合には、転置されたフィールドを持つテーブルか、フィーチャクラスのいずれを出力するかを選択できます。フィーチャクラスを出力するには、[属性フィールド] で [Shape] を選択する必要があります。
フィーチャクラスが入力である場合、フィーチャクラスの出力を取得する唯一の方法は、[属性フィールド] パラメータで [Shape] フィールドを選択することです。
構文
パラメータ | 説明 | データ タイプ |
in_table |
データ値を含むフィールドを転置する、入力フィーチャクラスまたはテーブル。 | Table View |
in_field [[field, {value}],...] |
転置が必要な、入力テーブルのデータ値を含むフィールドまたは列。 必要に応じて、転置が必要な複数のフィールドを選択できます。デフォルトでは、値はフィールド名と同じです。ただし、独自の値を指定することもできます。たとえば、転置したいフィールドのフィールド名が「Pop1991」、「Pop1992」などの場合、デフォルトでは、これらのフィールドの値も同じ(Pop1991、Pop1992)になります。ただし、1991 や 1992 などの独自の値を指定することも選択できます。 | Value Table |
out_table | 出力フィーチャクラスまたはテーブル。出力フィーチャクラスまたはテーブルには、転置されたフィールド、値フィールド、および入力テーブルからの継承が必要な、任意の数の指定された属性フィールドが含まれます。 out_table に指定したテーブルが出力されます(in_table の値がフィーチャクラスであり、attribute_fields パラメータで Shape フィールドが選択されている場合を除く)。 | Table |
in_transposed_field_name |
転置対象として選択したフィールドの、フィールド名の値を格納するために作成するフィールドの名前。任意の有効なフィールド名を使用できます。 | String |
in_value_field_name |
入力テーブルの値を格納するために作成する値フィールドの名前。入力テーブルまたはフィーチャクラスの既存のフィールド名と競合しない限り、任意の有効なフィールド名を設定できます。 | String |
attribute_fields [attribute_fields,...] (オプション) |
出力テーブルに含める、入力テーブルの属性フィールド。フィーチャクラスを出力したい場合は、Shape フィールドを選択します。 | Field |
コードのサンプル
次の Python ウィンドウ スクリプトは、イミディエイト モードで TransposeFields(フィールドの転置)ツールを使用する方法を示しています。
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(フィールドの転置)ツールの使用方法を示しています。
# 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)