I am creating a new pandas dataframe from a previous dataframe using the .groupby
and .size
methods.
[in] results = df.groupby(["X", "Y", "Z", "F"]).size()
[out]
9 27/02/2016 1 N 326
9 27/02/2016 1 S 332
9 27/02/2016 2 N 280
9 27/02/2016 2 S 353
9 27/02/2016 3 N 177
This behaves as expected, however the result is a dataframe with no column headers.
This SO question states that the following adds column names to the generated dataframe
[in] results.columns = ["X","Y","Z","F","Count"]
However, this does not seem to have any impact at all.
[out]
9 27/02/2016 1 N 326
9 27/02/2016 1 S 332
9 27/02/2016 2 N 280
9 27/02/2016 2 S 353
9 27/02/2016 3 N 177