I'm somewhat new to pandas. I have a pandas data frame that is 1 row by 23 columns.
I want to convert this into a series. I'm wondering what the most pythonic way to do this is?
I've tried pd.Series(myResults)
but it complains ValueError: cannot copy sequence with size 23 to array axis with dimension 1
. It's not smart enough to realize it's still a "vector" in math terms.
If you have a one column dataframe df, you can convert it to a series:
df.iloc[:,0] # pandas Series
Since you have a one row dataframe df
, you can transpose it so you're in the previous case:
df.T.iloc[:,0]