Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

DataReshapers

Guides

  • Data reshaping functions

Tech Notes

  • Data transformation workflows
  • Long form data transformation
  • Wide form data transformation

Symbols

  • CrossTabulate
  • CrossTabulationMatrixQ
  • CrossTensorate
  • CrossTensorateSplit
  • DatasetToMatrix
  • GridTableForm
  • LongFormDataset
  • PivotLonger
  • RecordsSummary
  • RecordsToLongFormDataset
  • RecordsToWideFormDataset
  • SeparateColumn
  • ToAutomaticKeysAssociation
  • TypeOfDataToBeReshaped
  • WideFormDataset
Wide form data transformation
Introduction
Wide form in more detail
Data
Putting them all together
Long form data
References
Introduction
In this notebook we consider in more detail the (tabular) data transformation operation Wide form.
Remark: We use several Wolfram Function Repository (WFR) functions:
ExampleDataset
and
RandomTabularDataset
.
Load the paclet
In[75]:=
Needs["AntonAntonov`DataReshapers`"]
Data
Take a dataset with time series specified through separate columns and convert into easier to query dataset:
Get the Lake Mead levels data
In[76]:=
ExampleData[{"Statistics","LakeMeadLevels"},"LongDescription"]
Out[76]=
Elevation of Lake Mead at Hoover Dam, in feet, in years 1935-2009. The observation on January of 1935 was missing.
Get the Lake Mead levels dataset
In[77]:=
dsLakeData=ResourceFunction["ExampleDataset"][{"Statistics","LakeMeadLevels"}]
Out[77]=
Year
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
1935
0.0
708.7
701.7
752.4
806.6
909.1
928.4
925.9
920.8
1936
907.9
908.4
906.9
922.2
982.4
1015.5
1020.4
1024.4
1024.6
1937
1022.2
1026.2
1031.0
1044.6
1078.7
1096.6
1102.8
1099.6
1097.6
1938
1095.0
1094.85
1100.2
1109.2
1134.4
1165.6
1173.5
1171.95
1173.8
1939
1165.4
1157.4
1158.2
1162.9
1176.2
1183.45
1181.3
1177.35
1178.95
1940
1166.9
1166.0
1164.65
1164.85
1175.35
1182.15
1179.8
1176.1
1174.45
1941
1167.1
1167.55
1170.35
1175.85
1201.25
1215.55
1220.4
1216.5
1209.85
1942
1184.8
1176.75
1171.25
1182.9
1195.5
1213.15
1213.2
1210.4
1205.0
1943
1182.45
1179.6
1177.0
1180.6
1188.75
1199.4
1201.55
1199.65
1195.7
1944
1170.9
1164.2
1158.4
1158.1
1173.2
1194.85
1199.55
1193.9
1187.1
1945
1161.25
1155.75
1149.6
1147.4
1161.3
1174.55
1180.7
1177.95
1177.95
1946
1157.55
1151.65
1147.45
1148.2
1155.15
1163.95
1163.3
1161.25
1157.65
1947
1142.6
1133.1
1135.38
1134.49
1151.93
1169.64
1177.18
1180.13
1178.02
1948
1164.52
1158.8
1154.51
1158.77
1175.95
1192.15
1190.32
1186.95
1180.82
1949
1158.04
1150.99
1147.17
1148.28
1164.51
1189.07
1196.61
1193.17
1186.86
1950
1163.4
1156.7
1151.75
1152.13
1158.57
1173.95
1177.15
1173.36
1168.77
1951
1151.47
1168.02
1144.07
1141.34
1146.16
1163.53
1168.19
1167.0
1163.75
1952
1149.06
1143.0
1133.99
1141.96
1171.53
1198.06
1199.88
1195.74
1190.0
1953
1162.56
1157.12
1152.42
1148.4
1147.33
1165.11
1165.87
1163.38
1157.67
1954
1141.44
1138.22
1134.08
1130.26
1130.76
1129.88
1126.25
1120.82
1115.39
rows 1–20 of
75
columns 1–10 of
13
Long form data
Convert to long form
In[78]:=
dfLong=ResourceFunction["LongFormDataset"][dsLakeData,"Year","VariablesTo""Month","ValuesTo""Elevation"]
Out[78]=
Year
Month
Elevation
1935
Apr
752.4
1935
Aug
925.9
1935
Dec
908.4
1935
Feb
708.7
1935
Jan
0.0
1935
Jul
928.4
1935
Jun
909.1
1935
Mar
701.7
1935
May
806.6
1935
Nov
908.3
1935
Oct
914.9
1935
Sep
920.8
1936
Apr
922.2
1936
Aug
1024.4
1936
Dec
1023.5
1936
Feb
908.4
1936
Jan
907.9
1936
Jul
1020.4
1936
Jun
1015.5
1936
Mar
906.9
rows 1–20 of
900
Wide form in more detail
Convert the long form into wide form
In[79]:=
dfWide=
WideFormDataset
[dfLong,"Year","Month","Elevation"]
Out[79]=
Year
Apr
Aug
Dec
Feb
Jan
Jul
Jun
Mar
May
1935
752.4
925.9
908.4
708.7
0.0
928.4
909.1
701.7
806.6
1936
922.2
1024.4
1023.5
908.4
907.9
1020.4
1015.5
906.9
982.4
1937
1044.6
1099.6
1095.75
1026.2
1022.2
1102.8
1096.6
1031.0
1078.7
1938
1109.2
1171.95
1168.65
1094.85
1095.0
1173.5
1165.6
1100.2
1134.4
1939
1162.9
1177.35
1169.95
1157.4
1165.4
1181.3
1183.45
1158.2
1176.2
1940
1164.85
1176.1
1168.05
1166.0
1166.9
1179.8
1182.15
1164.65
1175.35
1941
1175.85
1216.5
1195.8
1167.55
1167.1
1220.4
1215.55
1170.35
1201.25
1942
1182.9
1210.4
1188.4
1176.75
1184.8
1213.2
1213.15
1171.25
1195.5
1943
1180.6
1199.65
1178.35
1179.6
1182.45
1201.55
1199.4
1177.0
1188.75
1944
1158.1
1193.9
1168.0
1164.2
1170.9
1199.55
1194.85
1158.4
1173.2
1945
1147.4
1177.95
1163.35
1155.75
1161.25
1180.7
1174.55
1149.6
1161.3
1946
1148.2
1161.25
1148.55
1151.65
1157.55
1163.3
1163.95
1147.45
1155.15
1947
1134.49
1180.13
1170.58
1133.1
1142.6
1177.18
1169.64
1135.38
1151.93
1948
1158.77
1186.95
1164.85
1158.8
1164.52
1190.32
1192.15
1154.51
1175.95
1949
1148.28
1193.17
1170.06
1150.99
1158.04
1196.61
1189.07
1147.17
1164.51
1950
1152.13
1173.36
1156.62
1156.7
1163.4
1177.15
1173.95
1151.75
1158.57
1951
1141.34
1167.0
1153.12
1168.02
1151.47
1168.19
1163.53
1144.07
1146.16
1952
1141.96
1195.74
1169.1
1143.0
1149.06
1199.88
1198.06
1133.99
1171.53
1953
1148.4
1163.38
1145.78
1157.12
1162.56
1165.87
1165.11
1152.42
1147.33
1954
1130.26
1120.82
1105.4
1138.22
1141.44
1126.25
1129.88
1134.08
1130.76
rows 1–20 of
75
columns 1–10 of
13
Putting them all together
Anscombe Quartet

Long form & Wide form

Get Anscombe's dataset
In[80]:=
dsAnscombe=ResourceFunction["ExampleDataset"][{"Statistics","AnscombeRegressionLines"}]
Out[80]=
X1
X2
X3
X4
Y1
Y2
Y3
Y4
10
10
10
8
8.04
9.14
7.46
6.58
8
8
8
8
6.95
8.14
6.77
5.76
13
13
13
8
7.58
8.74
12.74
7.71
9
9
9
8
8.81
8.77
7.11
8.84
11
11
11
8
8.33
9.26
7.81
8.47
14
14
14
8
9.96
8.1
8.84
7.04
6
6
6
8
7.24
6.13
6.08
5.25
4
4
4
19
4.26
3.1
5.39
12.5
12
12
12
8
10.84
9.13
8.15
5.56
7
7
7
8
4.82
7.26
6.42
7.91
5
5
5
8
5.68
4.74
5.73
6.89
1) Convert Anscombe's dataset into long from.
2) Separate the column "Variable" into the columns "Variable" and "Set".
3) Convert the long form into wide form using "Set" and "AutomaticKey" as identifier columns

Direct manipulation

Transpose Anscombe's dataset
Group by dataset index and list plot the points of each group
References

© 2025 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com