You can replace the columns by a multi-index and stack:
df.columns = pd.MultiIndex.from_tuples(df.columns.str.split('_').map(tuple))
df = df.stack()
More Related Contents:
- converting a text file to csv file with out index
- Get the row(s) which have the max value in groups using groupby
- Error: pandas hashtable keyerror
- Writing a pandas DataFrame to CSV file
- pandas: How do I split text in a column into multiple rows?
- Find row where values for column is maximal in a pandas DataFrame
- Fast Haversine Approximation (Python/Pandas)
- How to filter rows containing a string pattern from a Pandas dataframe [duplicate]
- python/pandas: convert month int to month name
- How to form tuple column from two columns in Pandas
- Convert pandas Series to DataFrame
- How to keep leading zeros in a column when reading CSV with Pandas?
- Seaborn showing scientific notation in heatmap for 3-digit numbers
- Format certain floating dataframe columns into percentage in pandas
- Comparing two pandas dataframes for differences
- Read XLSB File in Pandas Python
- Print very long string completely in pandas dataframe
- pandas comparison raises TypeError: cannot compare a dtyped [float64] array with a scalar of type [bool]
- How do I filter a pandas DataFrame based on value counts?
- Lambda including if…elif…else
- Create bool mask from filter results in Pandas [duplicate]
- Getting a list of indices where pandas boolean series is True
- Pandas DataFrame sort by categorical column but by specific class ordering
- How can I remove extra whitespace from strings when parsing a csv file in Pandas?
- convert entire pandas dataframe to integers in pandas (0.17.0)
- Remove NaN values from pandas dataframe and reshape table [duplicate]
- How to convert DataFrame.append() to pandas.concat()?
- how to save a pandas DataFrame to an excel file?
- How to efficiently assign unique ID to individuals with multiple entries based on name in very large df
- Add image annotations to bar plots