0 votes
1 view
in Data Science by (17.6k points)

I tried:

x=pandas.DataFrame(...)

s = x.take([0], axis=1)

And s gets a DataFrame, not a Series.

1 Answer

0 votes
by (32.5k points)

This will give the first column of a pandas DataFrame as a series:

 import pandas as pd

 df = pd.DataFrame({'x' : [1, 2, 3, 4], 'y' : [4, 5, 6, 7]})

 df

   x  y

0  1 4

1  2 5

2  3 6

3  4 7

 s = df.ix[:,0]

 type(s)

<class 'pandas.core.series.Series'>

Related questions

0 votes
2 answers
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...