There are various other methods that are related to reshaping DataFrames; we'll discuss them here.
Other methods for reshaping DataFrames
Using the melt function
The melt function enables us to transform a DataFrame by designating some of its columns as ID columns, ensuring they remain as columns with the remaining non-ID columns treated as variable columns and are pivoted and become part of a name-value two-column scheme. ID columns uniquely identify a row in a DataFrame.
The names of those non-ID columns can be customized by supplying the var_name and value_name parameters. The use of melt is perhaps best illustrated by an example, as follows:
In [385]: from pandas.core.reshape import melt In [401]: USIndexDataDF...