0

Why does the returned dataframe contain the order_dow column twice?

Am I doing something wrong? I am pretty new to this , any help would be much appreciated :)

screenshot of code and output (dataframe head and plot)

the code + what it returns

I was expecting a 2x7 Dataframe containing on the first column the index of the days (0-6) and on the second column the count of the occurrences of each value.

wjandrea
  • 28,235
  • 9
  • 60
  • 81
  • 1
    Welcome to Stack Overflow! Check out the [tour]. It'd help to provide a [reproducible pandas example](/q/20109391/4518341). For more tips, see [mre] and [ask]. – wjandrea Nov 14 '22 at 20:20
  • 1
    More importantly, [don't post pictures of text](https://meta.stackoverflow.com/q/285551/4518341). Instead, copy the text itself, [edit] it into your post, and use the formatting tools like [code formatting](/editing-help#code). You don't need to include the plot. – wjandrea Nov 14 '22 at 20:24
  • 1
    Oh, actually, this seems like just a basic misunderstanding. Groupby isn't actually doing anything here. You should do `.value_counts()` directly on the column. It's not clear why you thought groupby was necessary -- maybe you saw other examples using [`DataFrameGroupBy.value_counts()`](https://pandas.pydata.org/docs/reference/api/pandas.core.groupby.DataFrameGroupBy.value_counts.html) and thought you'd do the same on a column. – wjandrea Nov 14 '22 at 20:37

0 Answers0