Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python get column from grouped dataframe

# You can also reset_index() on your groupby result to get back a dataframe with the name column now accessible.

import pandas as pd
df = pd.DataFrame({"a":[1,1,3], "b":[4,5.5,6], "c":[7,8,9], "name":["hello","hello","foo"]})

df_grouped = df.groupby(["a", "name"]).median().reset_index() # Resetting the index makes the column accessible

df_grouped.name

 #Output:
 0    hello
 1      foo
Comment

PREVIOUS NEXT
Code Example
Python :: replace comma with dot in column pandas 
Python :: matp[lotlib max y value 
Python :: seaborn plot histogram for all columns 
Python :: convert negative to positive in python 
Python :: how to show mean values on histogram in seaborn 
Python :: Bar Charts bokeh 
Python :: sorting values in dictionary in python 
Python :: tkinter responsive gui 
Python :: how to check if value is in list python 
Python :: tkinter toplevel 
Python :: install simple audio in python 
Python :: selenium undetected chromedriver error 
Python :: beautifulsoup import 
Python :: set points size in geopandas plot 
Python :: tkinter treeview clear 
Python :: np.eye 
Python :: temp python web server 
Python :: opencv black white image 
Python :: Python dir() built-in function 
Python :: rolling window pandas 
Python :: how to vonvert 1 d list to 2d list in pytohn 
Python :: flask set cookie 
Python :: python machine learning scale 
Python :: how to add space in st.write streamlit 
Python :: convert nan to string pandas 
Python :: plot neural network keras 
Python :: python ctypes maximize window 
Python :: how to access the last element of a list in python 
Python :: how to access http page in pythion 
Python :: string in list python 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =