i'm running a function in which a variable is of pandas.core.series.Series type.
type of the series shown below.
<class 'pandas.core.series.Series'>
product_id_y 1159730
count 1
Name: 6159402, dtype: object
i want to convert this into a dataframe,such that, i get
product_id_y count
1159730 1
i tried doing this:
series1 = series1.to_frame()
but getting wrong result
after converting to dataframe
6159402
product_id_y 1159730
count 1
after doing reset index i'e series1 = series1.reset_index()
index 6159402
0 product_id_y 1159730
1 count 1
is there anny other way to do this??
Sample:
You can print by converting the series/dataframe to string:
You was very close, first
to_frame
and then transpose byT
:Another solution with
DataFrame
constructor: