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\',inpl
Try swapping the indices in the brackets:
df.iloc[:,0]
This should work.
Swapping the indices would solve the problem easily:
In [64]: type(df.iloc[0:,])
Out[64]: pandas.core.frame.DataFrame
In [65]: df.iloc[[:,0] // Swaped the indices
Out[65]:
score
gene
foo 4
bar 3
s = df.squeeze()
>>> s
gene
foo 4
bar 3
Name: score, dtype: float64
To get it back to a dataframe:
>>> s.to_frame()
score
gene
foo 4
bar 3