Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to reshape dataframe in python

# Importing modules
import pandas as pd
import numpy as np

# Create a dataframe
df = pd.DataFrame(np.random.randn(
    5, 4), index='A B C D E'.split(), columns='W X Y Z'.split())
print(df)

# Reshape the dataframe
df = df.stack().reset_index()
print(df)
Comment

PREVIOUS NEXT
Code Example
Python :: duplicate in list 
Python :: extract DATE from pandas 
Python :: discord bot delete messages python 
Python :: python print n numbers 
Python :: pandas resample groupby 
Python :: cv2.copyMakeBorder 
Python :: pyqt remove widget 
Python :: how to find permutation of numbers in python 
Python :: check setuptools version python 
Python :: python for loop in array 
Python :: python first three characters of string 
Python :: filter dict by list of keys python 
Python :: max heap python 
Python :: check if variable is function python 
Python :: how to select top 5 in every group pandas 
Python :: convert a string into a list in Python 
Python :: pandas rename 
Python :: set environment variable flask app 
Python :: change forms labels django 
Python :: python serial readline 
Python :: python string find 
Python :: how to find the path of a python module 
Python :: python dictionary multiple same keys 
Python :: how to see the whole dataset in jupyterlab 
Python :: subprocess.popen no output 
Python :: install json on python 
Python :: python node class 
Python :: python convert object to json 
Python :: csv to python dictionary 
Python :: create file in a specific directory python 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =