product_id
, a constant string as store
, and store1
as price
from the Products
table where store1
is not null.store2
and store3
.product_id
, store
, and price
, with rows only for non-null prices.melt()
function on the products
DataFrame, specifying product_id
as the identifier variable (id_vars
), and the store columns as the variables to unpivot (value_vars
).store
and price
, respectively.price
column using the dropna()
method.product_id
, store
, and price
columns.erDiagram Products { int product_id PK int store1 int store2 int store3 }