def dataframe_wide_to_long_indexed(df, column):
"""
Convert DataFrame from wide to long format using specified column as index column,
followed by indexing the DataFrame on the very same column and finally sorting it.
See also:
- http://pandas.pydata.org/pandas-docs/stable/reshaping.html#reshaping-by-melt
- http://stackoverflow.com/questions/17688155/complicated-for-me-reshaping-from-wide-to-long-in-pandas
"""
df = pandas.melt(df, id_vars=column).dropna()
df = dataframe_index_and_sort(df, column)
return df
评论列表
文章目录