Search
 
SCRIPT & CODE EXAMPLE
 

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')
Comment

PREVIOUS NEXT
Code Example
Python :: one liner if else replacement in python 
Python :: ensure string length 2 python 
Python :: without using sum add item in list python 
Python :: matplotlib 3.4.1 und csv 
Python :: pycaw , Python Audio Control Lib 
Python :: merge df datacamp 
Python :: how to download multiple googel images using python 
Python :: multipart encoder 
Python :: python -m pip install --upgrade pip /usr/bin/python: No module named pip 
Python :: numpy count occurrences in interval array 
Python :: flask admin forgeign keys show literal 
Python :: daraframe get top n max value 
Python :: To install a specific version, type the package name followed by the required version: 
Python :: import numpy illegal instruction (core dumped) jetson nano 
Python :: gravar arquivo python 
Python :: Using np.unravel_index on argmax output 
Python :: how to calculate chi square in python 
Python :: Python Split list into chunks using lambda Method 
Python :: python get all items exept las from array 
Python :: duplicate a list with lowercase in python 
Python :: compute difference of all the combinations of 2 arrays 
Python :: django router multiple pk 
Python :: Python downsampling 
Python :: how to search for element in list python 
Python :: flask buildspec.yml 
Python :: is complex datatype immutable in python 
Python :: python enumerate in list comprehension with if statement 
Python :: float python precision 
Python :: how to create a login page in python 
Python :: =adaqtar 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =