Answer the question
In order to leave comments, you need to log in
Question on combining pandas and seriaes?
Good afternoon!
I can’t think of something
There is a DataFrame
state = ['California', 'Texas', 'New York', 'Florida', 'Illinois']
area = [423967, 695662, 141297, 170312, 149995]
cl = ['tropic', 'tropic', 'norm', 'tropic', 'norm']
pop = [ 38332521, 26448193, 19651127, 19552860, 12882135]
data = pd.DataFrame({'state' : state, 'cl' : cl, 'area':area, 'pop':pop})
data_1 = data.groupby(['state', 'cl', 'area'])['pop'].median()
Answer the question
In order to leave comments, you need to log in
It looks like you did everything to confuse those who try to help you.
Let's start with the title of the question. How can panda s and seriae s be combined ?? Without even mentioning the unknown second of these terms - let's assume you meant Series - how can one UNION a Pandas module and an object of type Series ??
We go further.
We take your dataframe.
state cl area pop
0 California tropic 423967 38332521
1 Texas tropic 695662 26448193
2 New York norm 141297 19651127
3 Florida tropic 170312 19552860
4 Illinois norm 149995 12882135
data_1 = data.groupby(['cl'])['pop'].median()
cl
norm 16266631
tropic 26448193
MultiIndex([('California', 'tropic', 423967),
( 'Florida', 'tropic', 170312),
( 'Illinois', 'norm', 149995),
( 'New York', 'norm', 141297),
( 'Texas', 'tropic', 695662)],
names=['state', 'cl', 'area'])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question