8. Reshape

Reshape the Data into Long or Wide Format

  1. Click the Reshape under the Data Analysis category.

  1. Reshape type: Select a reshape type.

    1. Pivot: Reorganize the data into a wide data format.

    2. Pivot Table: Reorganize the data into a wide data format, and apply the Aggregation function if there are duplicate indexes or columns.

    3. Melt: Reorganize the data into a long data format.


Pivot & Pivot Table

  1. DataFrame: Select the dataframe that will be reconstructed with wide data.

  2. Index: Select a column to set as the index in the reorganized dataframe.

  3. Columns: Select the columns you want to set as columns in the reorganized dataframe.

  4. Values: Select the columns you want to populate with values for each column in the reorganized dataframe.

  5. Aggregate (Pivot Table): Select the aggregation function you want to apply to the duplicate indexes or columns. If you select multiple aggregation functions, the results of each function are generated separately.

    1. For example, applying the Count and First aggregation functions to columns A, B, and C results in a total of six columns.

  6. User Option: You can add options beyond what Visual Python provides.

  7. Allocate to: Specify a variable name to assign to the result.

  8. Reset Index: Reset the index to specify a new default integer index.

  9. Code View: Preview the code that will be output.

  10. Data View: Preview the output to be printed.

  11. Run: Print and run the code.


Melt

  1. DataFrame: Select the dataframe that will be reconstructed with long data.

  2. Id: Select the column(s) you want to designate as fixed variables in the reorganized dataframe. These columns will remain intact in the reorganized dataframe.

  3. The names of the column(s) selected in Value are populated in the Var name column of the reconstructed dataframe, and the values are populated in the Value name column.

  4. User Option: You can add options beyond what Visual Python provides.

  5. Allocate to: Specify a variable name to assign to the result.

  6. Reset Index: Reset the index to specify a new default integer index.

  7. Code View: Preview the code that will be output.

  8. Data View: Preview the output that will be printed.

  9. Run: Print and run the code.

Last updated