unpivot | teradatamlspk | pyspark2teradataml - unpivot - Teradata Package for Python

Teradata® pyspark2teradataml User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00
Published
December 2024
ft:locale
en-US
ft:lastEdition
2024-12-18
dita:mapPath
oeg1710443196055.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
oeg1710443196055
Product Category
Teradata Vantage

In teradatamlspk, the output column name for the columns passed as column expression to unpivot is different in the output DataFrame compared with PySpark.

PySpark

>>> df.unpivot(df.accounts, [(df.Jan*2)+df.Feb], "var", "val").show()
+----------+-----------------+-----+
|  accounts|              var|  val|
+----------+-----------------+-----+
|   Red Inc|((Jan * 2) + Feb)|500.0|
|  Alpha Co|((Jan * 2) + Feb)|610.0|
|Yellow Inc|((Jan * 2) + Feb)| NULL|
|Orange Inc|((Jan * 2) + Feb)| NULL|
|  Blue Inc|((Jan * 2) + Feb)|190.0|
| Jones LLC|((Jan * 2) + Feb)|500.0|
+----------+-----------------+-----+

teradatamlspk

>>> df.unpivot(df.accounts, [(df.Jan*2)+df.Feb], "var", "val").show()
+----------+-------------+-----+
|  accounts|          var|  val|
+----------+-------------+-----+
|   Red Inc|Jan * 2 + Feb|500.0|
|  Alpha Co|Jan * 2 + Feb|610.0|
|Yellow Inc|Jan * 2 + Feb| None|
|Orange Inc|Jan * 2 + Feb| None|
|  Blue Inc|Jan * 2 + Feb|190.0|
| Jones LLC|Jan * 2 + Feb|500.0|
+----------+-------------+-----+