util.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:kotori 作者: daq-tools 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号