I am new to Python and programming in general. I have some experience with R and finding pandas a little difficult.
I am trying to conduct a frequency count and then return this as a DataFrame object.
df = pd.read_csv('gender_data.csv')
x = df['Gender'].value_counts()
This returns the following series object:
Gender
Male 200
Female 100
I want to convert this into a DataFrame object so I can plot and specify the axes information. This is where I am having a problem because .to_frame() cuts off the category label from the series.
x.to_frame()
returns
Gender
200
100
Is there a way to convert the series into a DataFrame and keep the category column? In R I think I could achieve this by using as.data.frame(x)