Tabular[data]

行のリストを表す矩形のデータから表形式オブジェクトを作成する.

Tabular[data,{key1,key2,…}]

keyiを表形式オブジェクトの列 i の名前として設定する.

詳細とオプション
Details and Options Details and Options
例題  
例  
スコープ  
表形式オブジェクトの作成  
データの抽出  
データクリーニング  
データの変換  
オプション  
Alignment  
Background  
BaselinePosition  
Show More Show More
ImageSize  
ItemDisplayFunction  
ItemSize  
ItemStyle  
Scrollbars  
ScrollPosition  
アプリケーション  
特性と関係  
考えられる問題  
関連項目
関連するガイド
履歴
引用書式

Tabular

Tabular[data]

行のリストを表す矩形のデータから表形式オブジェクトを作成する.

Tabular[data,{key1,key2,…}]

keyiを表形式オブジェクトの列 i の名前として設定する.

詳細とオプション

  • Tabularは,データフレーム,表,あるいは構造化データとしても知られている.
  • Tabularは,一般に,各列が変数を,各行が測定値を表すデータを表すために使われる.通常は,データウィンドウのみが表示される.
  • 各列は,数,文字列,日付,式のような要素型を持つ.データ項目は欠落していてもよい.
  • 次は,data の可能な形式である.
  • {row1,row2,…}行のリストとしての行列 »
    {assoc1,assoc2,…}共通のキーを持つ連想のリスト »
    SparseArray[…],QuantityArray[…],…特殊行列表現 »
    Dataset[…]矩形データ集合 »
  • ToTabularを使って式のより多くの型をTabularに変換したり変換方法を詳細に制御したりすることができる.
  • Tabular[data,schm]は表形式 data のスキーマを設定したり変更したりする.ここで,schm はTabularSchemaオブジェクトあるいは連想<|"prop1"val1,…|>として与えられる.
  • SQLをバックエンドに持つ表形式オブジェクトは,Tabular[spec]の spec に以下の形式を使って構築できる.
  • RelationalDatabase[…]単一の表を含むリレーショナルデータベースオブジェクト
    RelationalDatabase[…]"table"リレーショナルデータベースから表を選ぶ
    <|"RelationalDatabase"RelationalDatabase[…],"Query""table"|>データベースからの表の拡張指定
  • Tabularは,Missing[],Null,Infinityのような欠落値あるいは例外的な値も認識して操作できる.
  • データ要素は,Part,Select等を使って抽出できる.
  • Tabularは,FromTabularあるいはNormalを使って他の形式に変換できる.
  • Tabularは,TransformColumnsやAggregateRowsのような変換関数に使うことができる.
  • Tabular[tabular,options] は,指定されたオプションをTabular オブジェクトに適用する.
  • 次のオプションは,Tabularの全体的な外観を制御する.
  • AllowedDimensionsAutomatic行数あるいは列数に対する制限
    AppearanceElementsAutomatic表示ビューに含める要素
    BaselinePosition Automatic周囲のテキストのベースラインに何を揃えるか
    BaseStyle{}表形式のためのベーススタイル指定
    ImageMarginsAutomatic表示される表形式の周囲の余白
    ImageSize Automaticビューとしての表全体の大きさ
    Scrollbars {Automatic,Automatic}スクロールバーを含めるかどうか
    ScrollPosition Automaticスクロールが有効な場合のスクロール位置
  • AppearanceElementsの考えられる要素には,"RowHeaders","CollapsedRowHeaders","ColumnHeaders","CollapsedColumnHeaders","Frame"および"ResizeArea"が含まれる.
  • Tabularは,表形式の内容の外観を決定する以下のオプションを取る.
  • AlignmentAutomatic項目の水平方向および垂直方向の配置
    BackgroundNone使用する背景色
    DividersAutomaticセル間に区切り線を含めるかどうか
    HeaderAlignmentAutomaticヘッダの水平方向および垂直方向の配置
    HeaderBackgroundAutomaticヘッダに使用する背景色
    HeaderSizeAutomaticヘッダの幅および高さ
    HeaderStyleAutomaticヘッダのスタイル
    ItemDisplayFunctionNone項目をフォーマットするための関数
    ItemSizeAutomatic各項目の幅および高さ
    ItemStyle{}列および行のスタイル
  • コンテンツのオプションは opt<|"elem"spec,…|>という形式であり,ここで"elem"は spec が影響を与える要素を指定する.
  • 次は,使用可能な要素である.
  • "Columns"{s1,s2,…}位置によって列のスタイルを指定する
    "Rows"{s1,s2,…}位置によって行のスタイルを指定する
    "ColumnRules"{col1s1,…}キーによって列のスタイルを指定する
    "RowRules"{row1s1,…}インデックスによって行のスタイルを指定する
    "ItemRules"{{row1,col1}s1,…}行および列ごとに項目のスタイルを指定する
    "ColumnValueFunction"cf値によって列のスタイルを指定する
    "RowValueFunction"rf値によって行のスタイルを指定する
    "ItemValueFunction"if値によって項目のスタイルを指定する
  • "Columns"および"Rows"には次の形式が使える.
  • {s1,s2,…,sn}最初に s1から snまでを使い,その後デフォルトの値を使う
    sすべての場合に s を使う
    Cyclic[{c1,c2,…}]すべての場合に ciを巡回的に使う
    {s1,s2,…,Cyclic[{c1,c2,…}],sm,…,sn}初めに siの最初のシーケンスを使い,その後 ciを巡回的に使い,最後に siの最後のシーケンスを使う
    {s1,s2,…,Cyclic[{}],sm,…,sn}初めに siの最初のシーケンスを使い,最後に最後のシーケンスを使う
  • 列 coliは,列キー"key"または列の数値インデックス i でよい.
  • 行 rowiは,Tabularがキー列を含む場合は,その行の数値インデックス i またはRowKey[{…}]でよい.
  • "RowValueFunction"f は,関数 f をデータの各行に適用し,各行全体に使用する設定を返すか,各列ごとにどの設定を使用するかを示す keyval の結果のリストを返さなければならない.
  • "ItemValueFunction"には次の形式を使うことができる.
  • itfnそれぞれの項目の設定を生成するために itfn を使う
    {col1itfn1,…}}itfniを coli 列の項目の設定生成のために使う
  • 項目値関数に渡される引数は,項目の値である val,表形式における位置{row,col}および表形式オブジェクト tab 全体である.
  • "RowValueFunction"には次の形式を使うことができる.
  • rwfnそれぞれの項目の設定を生成するために rwfn を使う
    {col1rwfni,…}}rwfn を使って列 coli内の項目の設定を生成する
  • 行値関数に渡される引数は,行の要素からなる連想 assoc,表形式内の行の位置 row,および表形式オブジェクト tab 全体である.

例題

すべて開く すべて閉じる

例  (5)

行列からTabularオブジェクトを作成する:

Wolfram Language code: Tabular[{{1, 2, 3}, {4, 5, 6}}]

列のキーを指定して,行列からTabularオブジェクトを作成する:

Wolfram Language code: Tabular[{{1, x, Today}, {4, y, Tomorrow}}, {"col1", "col2", "col3"}]

共通のキーを持つ連想のリストからTabularオブジェクトを作成する:

Wolfram Language code: Tabular[{<|"a" -> 1, "b" -> 2, "c" -> 3|>, <|"a" -> 4, "b" -> 5, "c" -> 6|>}]

列のリストからTabularオブジェクトを作成する:

Wolfram Language code: ToTabular[{"a" -> {1, 4}, "b" -> {2, 5}, "c" -> {3, 6}}, "Columns"]

DatasetからTabularオブジェクトを作成する:

Wolfram Language code: Tabular[Dataset[{Association["a" -> 1, "b" -> 2, "c" -> 3], Association["a" -> 4, "b" -> 5, "c" -> 6]}]]

スコープ  (27)

表形式オブジェクトの作成  (11)

行のリストからTabularオブジェクトを構築する:

Wolfram Language code: Tabular[{{"M", 8.1, 16.1}, {"M", 13.9, 29.2}, {"M", 16.1, 33.8}, {"F", 7.2, 14.7}, {"F", 14.9, 30.1}}]

列名を指定して,行列からTabularオブジェクトを構築する:

Wolfram Language code: Tabular[{{1, 2}, {3, 4}, {5, 6}}, {"col1", "col2"}]

連想のリストからTabularオブジェクトを構築する:

Wolfram Language code: Tabular[{<|"name" -> "John", "age" -> 25|>, <|"name" -> "Anne", "age" -> 20|>, <|"name" -> "Rob", "age" -> Missing[]|>}]

ExtendedKeyキーを持つ連想のリストからTabularオブジェクトを構築する:

Wolfram Language code: Tabular[{<|ExtendedKey["AA", "a"] -> 1, ExtendedKey["AA", "b"] -> 2|>, <|ExtendedKey["AA", "a"] -> 3, ExtendedKey["AA", "b"] -> 4|>}]

QuantityArrayからTabularオブジェクトを作る:

Wolfram Language code: qa = QuantityArray[RandomReal[1, {6, 3}], {"Meters", "Seconds", "Grams"}]
Wolfram Language code: Tabular[qa]

列指向のリストデータからのTabularオブジェクトにはTransposeが必要である:

Wolfram Language code: dates = RandomDate[5, DateGranularity -> "Day"]
Wolfram Language code: values = {1.2, 7.3, 3.8, 4.2, 4.5};
Wolfram Language code: Tabular[Transpose[{dates, values}], {"date", "value"}]

代りにToTabularを使う:

Wolfram Language code: ToTabular[{"date" -> dates, "value" -> values}, "Columns"]

DatasetをTabularオブジェクトに変換する:

Wolfram Language code: data = Take[ExampleData[{"Dataset", "Planets"}], 4]

Tabularを変換するとデータ集合の構造が平坦化される:

Wolfram Language code: Tabular[data]

"CSV"のImportを使って自動的にTabularオブジェクトを取得する:

Wolfram Language code: Import["ExampleData/TreesOwnedByTheCityOfChampaign.csv", "Tabular"]

"TSV"ファイルをインポートする:

Wolfram Language code: Import["ExampleData/RetailSales.tsv", "Tabular"]

各列の型を指定して,数のTabularオブジェクトを構築する:

Wolfram Language code: Tabular[{{1, 2}, {3, 4}, {5, 6}}, <|"ElementType" -> {"Integer64", "Integer16"}|>]

保存された型をチェックする:

Wolfram Language code: ColumnTypes[%]

異なる型の列を混ぜる:

Wolfram Language code: Tabular[{{1, "dog", True}, {2, "cow", False}}, <|"ElementType" -> {"Integer8", "String", "Boolean"}|>]

保存された型をチェックする:

Wolfram Language code: ColumnTypes[%]

行が実体で列が実体の特性であるTabularオブジェクトを表示する:

Wolfram Language code: EntityValue["Country", {"Area", "HighestElevation", "Population", "PopulationDensity"}, "Tabular"]

データの抽出  (9)

単一の要素を抽出する:

Wolfram Language code: tab = Tabular[{{1, 2}, {3, 4}}]
Wolfram Language code: tab[[1, 2]]

単一の要素を持つTabularオブジェクトを抽出する:

Wolfram Language code: tab[[{1}, {2}]]
Wolfram Language code: Normal[%]

行を抽出する:

Wolfram Language code: Tabular[{{1, 2}, {3, 4}}]
Wolfram Language code: %[[1]]
Wolfram Language code: Normal[%]

列を抽出する:

Wolfram Language code: Tabular[{{1, 2}, {3, 4}}]
Wolfram Language code: %[[All, 1]]
Wolfram Language code: Normal[%]

列のキーを使って列を抽出する:

Wolfram Language code: tab = Tabular[{<|"a" -> 1, "b" -> 0|>, <|"a" -> 1, "b" -> 1|>, <|"a" -> 2, "b" -> 0|>, <|"a" -> 2, "b" -> 1|>}]
Wolfram Language code: tab[[All, "b"]]
Wolfram Language code: Normal[%]

キー列があるTabularオブジェクトの行を抽出する:

Wolfram Language code: tab = Tabular[{{"one", True, "foo"}, {"two", False, "bar"}}, <|"ColumnKeys" -> {"key", "col1", "col2"}, "KeyColumns" -> {"key"}|>]
Wolfram Language code: tab[Key["one"]]
Wolfram Language code: tab[RowKey["one"]]
Wolfram Language code: tab[<|"key" -> "one"|>]

いくつかのキー列があるTabularオブジェクトから1行抽出する:

Wolfram Language code: tab = Tabular[{{"one", True, "foo"}, {"two", False, "bar"}}, <|"ColumnKeys" -> {"key1", "key2", "col"}, "KeyColumns" -> {"key1", "key2"}|>]
Wolfram Language code: tab[Key[{"one", True}]]
Wolfram Language code: tab[RowKey[{"one", True}]]
Wolfram Language code: tab[<|"key1" -> "one", "key2" -> True|>]

Tabularオブジェクトから複数の列を抽出する:

Wolfram Language code: tab = ResourceData["Sample Tabular Data: Fisher Iris"]

2列を抽出し,その順序を入れ替える:

Wolfram Language code: tab[[All, {3, 2}]]

列のキーを使って複数の列を抽出する:

Wolfram Language code: tab[[All, {"Species", "PetalLength", "SepalLength"}]]

条件を使って行を選択する:

Wolfram Language code: tab = ResourceData["Sample Tabular Data: Fisher Iris"]

"SepalLength"が6以上のすべての行を抽出する:

Wolfram Language code: Select[tab, #SepalLength >= Quantity[7, "Centimeters"]&]

列の型を使って列を選択する:

Wolfram Language code: tab = Tabular[{{"M", 8.1, 16.1}, {"M", 13.9, 29.2}, {"M", 16.1, 33.8}, {"F", 7.2, 14.7}, {"F", 14.9, 30.1}}, {"MF", "val1", "val2"}]

数値型の列を選択する:

Wolfram Language code: ColumnKeys[tab, #ElementType === "Real64"&]
Wolfram Language code: tab[All, %]

データクリーニング  (4)

国データのTabularオブジェクトを取る:

Wolfram Language code: tab = EntityValue[EntityClass["Country", "Europe"], {"Population", "Area"}, "Tabular"]

人口の降順でソートする:

Wolfram Language code: ReverseSortBy[tab, "Population"]

面積が最も狭い国を求める:

Wolfram Language code: MinimalBy[tab, "Area"]

列を削除する:

Wolfram Language code: Tabular[{{1, 2}, {3, 4}, {5, 6}}, {"col1", "col2"}]
Wolfram Language code: DeleteColumns[%, "col2"]

列を挿入する:

Wolfram Language code: Tabular[{{1, 2}, {3, 4}, {5, 6}}, {"col1", "col2"}]
Wolfram Language code: InsertColumns[%, "col3" -> {"a", "b", "c"}]

列の名前を変える:

Wolfram Language code: Tabular[{{1, 2}, {3, 4}, {5, 6}}, {"col1", "col2"}]
Wolfram Language code: RenameColumns[%, "col2" -> "c2"]

データの変換  (3)

新たな列を構築する:

Wolfram Language code: times = DateRange[Today, Today + Quantity[4, "Days"]]; values = {1.2, 7.3, 3.8, 4.2, 4.5}; Tabular[Transpose[{times, values}], {"date", "value"}]

最後の列を新しい列のままにする:

Wolfram Language code: ConstructColumns[%, {"day" -> Function[DayName[#date]], "value"}]

既存の列を変換する:

Wolfram Language code: dates = {"Sep 1, 2024", "Sep 2, 2024", "Sep 3, 2024"}; values = {1.2, 7.3, 3.8}; Tabular[Transpose[{dates, values}], {"date", "value"}]
Wolfram Language code: TransformColumns[%, "date" -> Function[FromDateString[#date]]]

ヨーロッパ諸国の人口と面積:

Wolfram Language code: tab = EntityValue[EntityClass["Country", "Europe"], {"Population", "Area"}, "Tabular"]

人口密度を計算する:

Wolfram Language code: TransformColumns[tab, "Density" -> Function[#Population / #Area]]

オプション  (46)

Alignment  (10)

すべての列に対して配置を指定する:

Wolfram Language code: Tabular[{{1, 2, 3}, {4, 5, 6}}, {"a", "b", "c"}, Alignment -> <|"Columns" -> {Left, Center, Right}|>]

列数が配置数より多い場合,後続の列にはデフォルト配置が適用される:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Alignment -> <|"Columns" -> {Center, Left}|>]

左右の列の配置を切り替える:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Alignment -> <|"Columns" -> Cyclic[{Left, Right}]|>]

開始と終了の列は中央揃えとし,その間の列には左揃えと右揃えを交互に適用する:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Alignment -> <|"Columns" -> {Center, Cyclic[{Left, Right}], Center}|>]

開始と終了の列は左揃えとし,中間の列にはデフォルトの配置を用いる:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Alignment -> <|"Columns" -> {Left, Cyclic[{}], Left}|>]

列"b"を左揃えにする:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Alignment -> <|"ColumnRules" -> {"b" -> Left}|>]

項目の配置を,その{row,col}の位置を用いて指定する:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Alignment -> <|"ItemRules" -> {{3, "b"} -> Left}|>]

列"b"の値が10より大きい場合にはその行を左揃えとし,それ以外の場合には右揃えとする:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Alignment -> <|"RowValueFunction" -> (If[#b > 10, Left, Right]&)|>]

デフォルトの配置にしたければ,Noneを使用するとよい:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Alignment -> <|"RowValueFunction" -> (If[#b > 10, Left, None]&)|>]

値が偶数の項目は左揃えとし,それ以外は中央揃えとする:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Alignment -> <|"ItemValueFunction" -> (If[EvenQ[#], Left, Center]&)|>]

Noneを使ってデフォルトの配置にする:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Alignment -> <|"ItemValueFunction" -> (If[EvenQ[#], Left, None]&)|>]

"b"列をその値に基づいて配置する:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Alignment -> <|"ItemValueFunction" -> {"b" -> (If[# > 10, Left, Right]&)}|>]

Background  (13)

すべての項目の背景に一つのスタイルを使う:

Wolfram Language code: Tabular[{{1, 2, 3}, {4, 5, 6}}, {"a", "b", "c"}, Background -> RGBColor[0.95, 0.627, 0.1425]]

各列の背景を指定する:

Wolfram Language code: Tabular[{{1, 2, 3}, {4, 5, 6}}, {"a", "b", "c"}, Background -> <|"Columns" -> {RGBColor[0.24, 0.6, 0.8], RGBColor[0.95, 0.627, 0.1425], RGBColor[0.455, 0.7, 0.21]}|>]

各行の背景を指定する:

Wolfram Language code: Tabular[{{1, 2, 3}, {4, 5, 6}}, {"a", "b", "c"}, Background -> <|"Rows" -> {RGBColor[0.24, 0.6, 0.8], RGBColor[0.95, 0.627, 0.1425]}|>]

スタイルよりも列数が多い場合は,後ろの列にデフォルトスタイルが使われる:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Background -> <|"Columns" -> {RGBColor[0.24, 0.6, 0.8], RGBColor[0.95, 0.627, 0.1425], RGBColor[0.455, 0.7, 0.21]}|>]

スタイルよりも行数が多い場合は,後ろの行にデフォルトスタイルが使われる:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Background -> <|"Rows" -> {RGBColor[0.24, 0.6, 0.8], RGBColor[0.95, 0.627, 0.1425]}|>]

列の背景に青と緑を交互に使う:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Background -> <|"Columns" -> Cyclic[{RGBColor[0.24, 0.6, 0.8], RGBColor[0.455, 0.7, 0.21]}]|>]

行の背景に青と緑を交互に使う:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {1, 3, 5, 7, 9}, {2, 4, 6, 8, 10}}, {"a", "b", "c", "d", "e"}, Background -> <|"Rows" -> Cyclic[{RGBColor[0.24, 0.6, 0.8], RGBColor[0.455, 0.7, 0.21]}]|>]

列の背景を最初は青,最後は赤にして,中間にはオレンジ色と緑を交互に使う:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Background -> <|"Columns" -> {RGBColor[0.24, 0.6, 0.8], Cyclic[{RGBColor[0.95, 0.627, 0.1425], RGBColor[0.455, 0.7, 0.21]}], RGBColor[0.922526, 0.385626, 0.209179]}|>]

行の背景を最初は青,最後は赤にして,中間にはオレンジ色と緑を交互に使う:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {1, 3, 5, 7, 9}, {2, 4, 6, 8, 10}}, {"a", "b", "c", "d", "e"}, Background -> <|"Rows" -> {RGBColor[0.24, 0.6, 0.8], Cyclic[{RGBColor[0.95, 0.627, 0.1425], RGBColor[0.455, 0.7, 0.21]}], RGBColor[0.922526, 0.385626, 0.209179]}|>]

列の背景を最初は青,最後は赤にして,中間にはデフォルトスタイルを使う:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Background -> <|"Columns" -> {RGBColor[0.24, 0.6, 0.8], Cyclic[{}], RGBColor[0.922526, 0.385626, 0.209179]}|>]

行の背景を最初は青,最後は赤にして,中間にはデフォルトスタイルを使う:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {1, 3, 5, 7, 9}, {2, 4, 6, 8, 10}}, {"a", "b", "c", "d", "e"}, Background -> <|"Rows" -> {RGBColor[0.24, 0.6, 0.8], Cyclic[{}], RGBColor[0.922526, 0.385626, 0.209179]}|>]

列"b"に青い背景を使う:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Background -> <|"ColumnRules" -> {"b" -> RGBColor[0.24, 0.6, 0.8]}|>]

2番目の行に青い背景を使う:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Background -> <|"RowRules" -> {2 -> RGBColor[0.24, 0.6, 0.8]}|>]

RowKey[{…}]を使って行にスタイル付けする:

Wolfram Language code: Tabular[{{"apple", 2, 3, 4, 5}, {"banana", 7, 8, 9, 10}, {"grape", 12, 13, 14, 15}}, <|...|>, Background -> <|"RowRules" -> {RowKey[{"banana"}] -> RGBColor[0.24, 0.6, 0.8]}|>]

{row,col}位置を使って項目の背景スタイルを指定する:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Background -> <|"ItemRules" -> {{3, "b"} -> RGBColor[0.24, 0.6, 0.8]}|>]

行の背景色を,列"b"の値が10を超える場合は赤,それ以外の場合は青にする:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Background -> <|"RowValueFunction" -> (If[#b > 10, RGBColor[0.91, 0.318, 0.243], RGBColor[0.24, 0.6, 0.8]]&)|>]

Noneを使ってデフォルトの背景スタイルにする:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Background -> <|"RowValueFunction" -> (If[#b > 10, RGBColor[0.91, 0.318, 0.243], None]&)|>]

"b"列の値に基づいて第2行を彩色する:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Background -> <|"RowValueFunction" -> {2 -> (If[#b > 10, RGBColor[0.91, 0.318, 0.243], RGBColor[0.24, 0.6, 0.8]]&)}|>]

項目の値が奇数の場合は背景色を赤に,それ以外の場合は青にする:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Background -> <|"ItemValueFunction" -> (If[EvenQ[#], RGBColor[0.91, 0.318, 0.243], RGBColor[0.24, 0.6, 0.8]]&)|>]

Noneを使ってデフォルトの背景スタイルにする:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Background -> <|"ItemValueFunction" -> (If[EvenQ[#], RGBColor[0.91, 0.318, 0.243], None]&)|>]

"b"列をその値に基づいて彩色する:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, Background -> <|"ItemValueFunction" -> {"b" -> (If[# > 10, RGBColor[0.91, 0.318, 0.243], RGBColor[0.24, 0.6, 0.8]]&)}|>]

BaselinePosition  (1)

表形式の中央を周囲のテキストのベースラインと揃える:

Wolfram Language code: {x, y, Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, BaselinePosition -> Center], z}

表形式の下端をベースラインと揃える:

Wolfram Language code: {x, y, Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, BaselinePosition -> Bottom], z}

ImageSize  (5)

デフォルトで,幅はノートブックのサイズによって制限され,表示される行数も限定される:

Wolfram Language code: ResourceData["Sample Tabular Data: Car Models"]

名前付きサイズを使用することで,Tabularオブジェクトの表示範囲が縮小できる:

Wolfram Language code: Tabular[ResourceData["Sample Tabular Data: Car Models"], ImageSize -> Small]

Tabularオブジェクトの幅を制限する:

Wolfram Language code: Tabular[ResourceData["Sample Tabular Data: Car Models"], ImageSize -> 300]

Tabularオブジェクトの幅および高さを制限する:

Wolfram Language code: Tabular[ResourceData["Sample Tabular Data: Car Models"], ImageSize -> {300, 100}]

Tabularオブジェクトの全体的な高さに制限を設ける:

Wolfram Language code: Tabular[ResourceData["Sample Tabular Data: Car Models"], ImageSize -> {Automatic, 100}]

ItemDisplayFunction  (1)

ItemDisplayFunctionを使って欠損値の表示方法を変える:

Wolfram Language code: Tabular[{{9, Missing[], 2, 3, 3}, {6, 3, 1, 3, 10}, {1, 7, 4, Missing[], Missing[]}, {5, 7, 6, 4, 3}, {9, 5, 4, 9, 6}}, ItemDisplayFunction -> (If[MissingQ[#], Style["●", StandardRed], #]&)]

ItemSize  (1)

項目の高さをItemSizeで増加させる:

Wolfram Language code: Tabular[ResourceData["Sample Tabular Data: Car Models"], ItemSize -> 3]

項目の幅と高さを指定する:

Wolfram Language code: Tabular[ResourceData["Sample Tabular Data: Car Models"], ItemSize -> {10, 3}]

Cyclicを使用して,2列目から最後までに繰り返される項目サイズを割り当てる:

Wolfram Language code: Tabular[ResourceData["Sample Tabular Data: Car Models"], ItemSize -> {{15, Cyclic[{5}]}, Automatic}]

ItemStyle  (13)

すべての項目のスタイルとして一つのスタイルを使う:

Wolfram Language code: Tabular[{{1, 2, 3}, {4, 5, 6}}, {"a", "b", "c"}, ItemStyle -> Bold]

Directiveを使って複数のスタイルを一つに組み合せる:

Wolfram Language code: Tabular[{{1, 2, 3}, {4, 5, 6}}, {"a", "b", "c"}, ItemStyle -> Directive[Bold, Italic]]

各列のスタイルを指定する:

Wolfram Language code: Tabular[{{1, 2, 3}, {4, 5, 6}}, {"a", "b", "c"}, ItemStyle -> <|"Columns" -> {Bold, Italic, Red}|>]

各行のスタイルを指定する:

Wolfram Language code: Tabular[{{1, 2, 3}, {4, 5, 6}}, {"a", "b", "c"}, ItemStyle -> <|"Rows" -> {Bold, Red}|>]

スタイルよりも列数が多い場合,後ろの列にはデフォルトのスタイルが使われる:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, ItemStyle -> <|"Columns" -> {RGBColor[0.24, 0.6, 0.8], RGBColor[0.95, 0.627, 0.1425], RGBColor[0.455, 0.7, 0.21]}|>]

スタイルよりも行数が多い場合,後ろの行にはデフォルトのスタイルが使われる:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, ItemStyle -> <|"Rows" -> {RGBColor[0.24, 0.6, 0.8], RGBColor[0.95, 0.627, 0.1425]}|>]

列のスタイルに青と緑を交互に使う:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, ItemStyle -> <|"Columns" -> Cyclic[{RGBColor[0.24, 0.6, 0.8], RGBColor[0.455, 0.7, 0.21]}]|>]

行のスタイルに青と緑を交互に使う:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {1, 3, 5, 7, 9}, {2, 4, 6, 8, 10}}, {"a", "b", "c", "d", "e"}, ItemStyle -> <|"Rows" -> Cyclic[{RGBColor[0.24, 0.6, 0.8], RGBColor[0.455, 0.7, 0.21]}]|>]

列のスタイルを最初は青,最後は赤とし,中間はオレンジ色と緑を交互に使う:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, ItemStyle -> <|"Columns" -> {RGBColor[0.24, 0.6, 0.8], Cyclic[{RGBColor[0.95, 0.627, 0.1425], RGBColor[0.455, 0.7, 0.21]}], RGBColor[0.922526, 0.385626, 0.209179]}|>]

行のスタイルを最初は青,最後は赤とし,中間はオレンジ色と緑を交互に使う:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {1, 3, 5, 7, 9}, {2, 4, 6, 8, 10}}, {"a", "b", "c", "d", "e"}, ItemStyle -> <|"Rows" -> {RGBColor[0.24, 0.6, 0.8], Cyclic[{RGBColor[0.95, 0.627, 0.1425], RGBColor[0.455, 0.7, 0.21]}], RGBColor[0.922526, 0.385626, 0.209179]}|>]

列のスタイルを最初は青,最後は赤とし,中間はデフォルトスタイルにする:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, ItemStyle -> <|"Columns" -> {RGBColor[0.24, 0.6, 0.8], Cyclic[{}], RGBColor[0.922526, 0.385626, 0.209179]}|>]

行のスタイルを最初は青,最後は赤とし,中間はデフォルトスタイルにする:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {1, 3, 5, 7, 9}, {2, 4, 6, 8, 10}}, {"a", "b", "c", "d", "e"}, ItemStyle -> <|"Rows" -> {RGBColor[0.24, 0.6, 0.8], Cyclic[{}], RGBColor[0.922526, 0.385626, 0.209179]}|>]

列"b"のスタイルを青にする:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, ItemStyle -> <|"ColumnRules" -> {"b" -> RGBColor[0.24, 0.6, 0.8]}|>]

第2行のスタイルを青にする:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, ItemStyle -> <|"RowRules" -> {2 -> RGBColor[0.24, 0.6, 0.8]}|>]

RowKey[{…}]を使って行にスタイル付けする:

Wolfram Language code: Tabular[{{"apple", 2, 3, 4, 5}, {"banana", 7, 8, 9, 10}, {"grape", 12, 13, 14, 15}}, <|...|>, ItemStyle -> <|"RowRules" -> {RowKey[{"banana"}] -> RGBColor[0.24, 0.6, 0.8]}|>]

{row,col}位置を使って項目のスタイルを指定する:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, ItemStyle -> <|"ItemRules" -> {{3, "b"} -> RGBColor[0.24, 0.6, 0.8]}|>]

行のスタイルを,列"b"の値が10より大きい場合は赤,それ以外の場合は青にする:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, ItemStyle -> <|"RowValueFunction" -> (If[#b > 10, RGBColor[0.91, 0.318, 0.243], RGBColor[0.24, 0.6, 0.8]]&)|>]

Noneを使ってデフォルトスタイルにする:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, ItemStyle -> <|"RowValueFunction" -> (If[#b > 10, RGBColor[0.91, 0.318, 0.243], None]&)|>]

"b"列の値に基づいて第2列を彩色する:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, ItemStyle -> <|"RowValueFunction" -> {2 -> (If[#b > 10, RGBColor[0.91, 0.318, 0.243], RGBColor[0.24, 0.6, 0.8]]&)}|>]

項目を,値が偶数の場合は赤に,それ以外の場合は青にする:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, ItemStyle -> <|"ItemValueFunction" -> (If[EvenQ[#], RGBColor[0.91, 0.318, 0.243], RGBColor[0.24, 0.6, 0.8]]&)|>]

Noneを使ってデフォルトスタイルにする:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, ItemStyle -> <|"ItemValueFunction" -> (If[EvenQ[#], RGBColor[0.91, 0.318, 0.243], None]&)|>]

"b"列をその値に基づいて彩色する:

Wolfram Language code: Tabular[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}, {"a", "b", "c", "d", "e"}, ItemStyle -> <|"ItemValueFunction" -> {"b" -> (If[# > 10, RGBColor[0.91, 0.318, 0.243], RGBColor[0.24, 0.6, 0.8]]&)}|>]

Scrollbars  (1)

表形式の内容が表示サイズより大きい場合,スクロールバーが表示される:

Wolfram Language code: Tabular[RandomReal[1, {20, 15}]]

列スクロールバーを非表示にする:

Wolfram Language code: Tabular[RandomReal[1, {20, 15}], Scrollbars -> {True, False}]

スクロールバーは使わない:

Wolfram Language code: Tabular[RandomReal[1, {20, 15}], Scrollbars -> False]

ScrollPosition  (1)

デフォルトでは,スクロールバーは内容の左上隅を表示する位置に配置される:

Wolfram Language code: Tabular[RandomReal[1, {20, 15}], ScrollPosition -> Automatic]

スクロールバーの初期位置をポイント単位でカスタム指定する:

Wolfram Language code: Tabular[RandomReal[1, {20, 15}], ScrollPosition -> {250, 0}]

ScrollPositionはDynamicオブジェクトでよい:

Wolfram Language code: Row[{Column[{Slider[Dynamic[h], {0, 500, 1}], Tabular[RandomReal[1, {20, 15}], ScrollPosition -> Dynamic[{h, v}], Scrollbars -> False, ImageSize -> {400, 300}]}], VerticalSlider[Dynamic[v], {300, 0}]}]

アプリケーション  (3)

Tabularオブジェクトを使って列データを別々の列のヘディングで表示する:

Wolfram Language code: name = {"Statistics", "FisherIris"};
Wolfram Language code: ExampleData[name, "LongDescription"]

配列データと"ColumnHeadings"特性を使ってTabularオブジェクトを作成する:

Wolfram Language code: tab = Tabular[ExampleData[name], ExampleData[name, "ColumnHeadings"]]

花びらの長さを萼の長さの関数としてプロットする:

Wolfram Language code: ListPlot[tab -> {"SepalLength", "PetalLength"}]

相関係数を求める:

Wolfram Language code: AggregateRows[tab, "corr" -> Function[Correlation[#SepalLength, #PetalLength]]]

種に応じた花の測定値の平均を計算する:

Wolfram Language code: AggregateRows[tab, {"SepalLengthMean" -> Function[Mean[#SepalLength]], "SepalWidthMean" -> Function[Mean[#SepalWidth]], "PetalLengthMean" -> Function[Mean[#PetalLength]], "PetalWidthMean" -> Function[Mean[#PetalWidth]]}, "Species"]

Tabular形式の"DuneBooks"についての情報:

Wolfram Language code: EntityValue[EntityClass["Book", "DuneBooks"], {"FirstPublished", "Author", "Image"}, "Tabular"]

ItemDisplayFunctionを使用してTabular列の分布グリフを表示し,そのグリフ上に現在の項目の値を示す.

まず,SmoothHistogramで分布プロットを生成する:

Wolfram Language code: g = SmoothHistogram[ResourceData["Sample Tabular Data: Car Models"] -> "mpg", PlotStyle -> LightGray, Axes -> None, AspectRatio -> 1 / 3, PlotRangePadding -> Scaled[.05], PlotInteractivity -> False]

項目値のところにマーカーを追加するグリフ関数を作成する:

Wolfram Language code: mpgGlyph[v_] := Labeled[Show[g, Epilog -> {RGBColor[0.91, 0.318, 0.243], Thick, InfiniteLine[{{v, 0}, {v, 1}}]}], v, Right]
Wolfram Language code: mpgGlyph[20]

ItemDisplayFunctionで表形式の列"mpg"に適用する:

Wolfram Language code: Tabular[ResourceData["Sample Tabular Data: Car Models"], ItemDisplayFunction -> <|"mpg" -> (mpgGlyph[#]&)|>]

特性と関係  (3)

TabularQを使ってTabularオブジェクトが有効かどうかを調べる:

Wolfram Language code: Tabular[{{1, 2}, {3, 4}}]
Wolfram Language code: TabularQ[%]

Tabularオブジェクトの列はTabularColumnオブジェクトとして与えられる:

Wolfram Language code: tab = Tabular[{{a, b}, {c, d}, {e, f}}]

第1列:

Wolfram Language code: tab[All, 1]
Wolfram Language code: Normal[%]

第2列:

Wolfram Language code: tab[All, 2]
Wolfram Language code: Normal[%]

Tabularオブジェクトの行はTabularRowオブジェクトとして与えられる:

Wolfram Language code: tab = Tabular[{{a, b, c}, {d, e, f}}]

第1行:

Wolfram Language code: tab[1]
Wolfram Language code: Normal[%]

第2行:

Wolfram Language code: tab[2]
Wolfram Language code: Normal[%]

考えられる問題  (3)

Tabular入力データは,少なくとも二次元でなければならない:

Wolfram Language code: Tabular[{x, y, z}]

単一の行を作成する:

Wolfram Language code: Tabular[{{x, y, z}}]

単一の列を作成する:

Wolfram Language code: Tabular[List /@ {x, y, z}]

第2レベルが不揃いなのは許容されない:

Wolfram Language code: Tabular[{{a, b}, {c}}]

配列の最初の2レベルは矩形でなければならない:

Wolfram Language code: Tabular[{{{a, b}, {c, d}}, {{A, B, X}, {C, D}}}]

充填することもできる:

Wolfram Language code: Tabular[PadRight[{{a, b}, {c}}, Automatic, Missing[]]]

Tabularオブジェクトは繰返される列キーを持つことはできない.これを持たせるとPart抽出によって重複されたものが削除される:

Wolfram Language code: tab = Tabular[{{1, True, Today}, {2, False, Tomorrow}}, {"col", "bool", "date"}]
Wolfram Language code: tab[[All, {"col", "col"}]]

Part抽出をマップして重複列を生成する:

Wolfram Language code: tab[[All, #]]& /@ {"col", "col"}

列キーがないあるいは異なる列キーを持つTabularオブジェクトを作成する:

Wolfram Language code: {Tabular[%], Tabular[%, {"a", "b"}]}
Wolfram Research (2025), Tabular, Wolfram言語関数, https://reference.wolfram.com/language/ref/Tabular.html (2025年に更新).

テキスト

Wolfram Research (2025), Tabular, Wolfram言語関数, https://reference.wolfram.com/language/ref/Tabular.html (2025年に更新).

CMS

Wolfram Language. 2025. "Tabular." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/Tabular.html.

APA

Wolfram Language. (2025). Tabular. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Tabular.html

BibTeX

@misc{reference.wolfram_2026_tabular, author="Wolfram Research", title="{Tabular}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/Tabular.html}", note=[Accessed: 31-August-2026]}

BibLaTeX

@online{reference.wolfram_2026_tabular, organization={Wolfram Research}, title={Tabular}, year={2025}, url={https://reference.wolfram.com/language/ref/Tabular.html}, note=[Accessed: 31-August-2026]}