Articles → Pandas → pivot_table function in dataframes in pandas

pivot_table function in dataframes in pandas






Purpose





Example


import pandas as pd


# Create a dictionary
dict = {
    "company": ["Google", "Microsoft", "Apple", "Google", "Microsoft", "Apple"],
    "year": [2017, 2017, 2017, 2018, 2018, 2018],
    "Profit": [20000, 40000, 60000, 80000, 70000, 50000],
}

df = pd.DataFrame(dict)

df.pivot_table(columns="company", values="year")



Output



Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, May 1, 2019

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250