I have the following data frame:
import pandas as pd
d = {'gene' : ['foo','bar'],'score' : [4., 3.,]}
df = pd.DataFrame(d)
df.set_index('gene',inplace=True)
Which make:
In [56]: df
Out[56]:
score
gene
foo 4
bar 3
In [58]: type(df)
Out[58]: pandas.core.frame.DataFrame
What I want to do is to turn it into a Series.
I expect it to to return:
gene
foo 4
bar 3
#pandas.core.series.Series
I tried this but it doesn't work:
In [64]: type(df.iloc[0:,])
Out[64]: pandas.core.frame.DataFrame
In [65]: df.iloc[0:,]
Out[65]:
score
gene
foo 4
bar 3
What's the right way to do it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…