Wide and narrow are terms used to describe two different presentations for tabular data.Thompson, M. E. (1997), Theory of sample surveys, Chapman & Hall, London. Chantala, K. (2006) "Using STATA to Analyze data from a Sample Survey" . 1-10-2001. UNC Chapel Hill, Carolina Population Center. 10-1-2006.

Terminology The terms used vary by community and software: Wide and long: Common in modern data science and time-series analysis (e.g., pandas, R). Un-stacked and stacked: Common in statistical software and spreadsheet operations. Pivoted and unpivoted: Common in SQL and data preparation tools like Power Query, where "unpivoting" refers to transforming wide data into a long format. Wide and narrow: Common in database modeling.

Wide Wide, or unstacked data is presented with each different data variable in a separate column. Person Age WeightHeight Bob 32 168180 Alice 24 150175 Steve 64 144165

Narrow

Narrow, stacked, or long data is presented with one column containing all the values and another column listing the context of the value Person Variable Value Bob Age 32 Bob Weight 168BobHeight180 Alice Age 24 Alice Weight 150AliceHeight175 Steve Age 64 Steve Weight 144SteveHeight165

This is often easier to implement; addition of a new field does not require any changes to the structure of the table, however it can be harder for people to understand.

Implementations Many statistical and data processing systems have functions to convert between these two presentations, for instance the R programming language has several packages such as the tidyr package. The pandas package in Python implements this operation as "melt" function which converts a wide table to a narrow one. The process of converting a narrow table to wide table is generally referred to as "pivoting" in the context of data transformations. The "pandas" python package provides a "pivot" method which provides for a narrow to wide transformation.

See also Abstract data type Pivot table Table (information) Information graphics Row (database) Table (database) Table (HTML)

References

External links

https://tidyr.tidyverse.org/articles/pivot.html https://cran.r-project.org/web/packages/reshape