Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python how to geather and spread using pandas

#Import pandas module
import pandas as pd

# Define the dataframe
DF = pd.DataFrame({'y': [1,4], 'female': [2,5], 'male': [3,6]})

# Gather/melt the data frame
pd.melt(DF, id_vars='y', value_vars=['female', 'male'],var_name='gender',
value_name='value')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #geather #spread #pandas
ADD COMMENT
Topic
Name
8+2 =