KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have the following data frame "DF" which is part of a much larger one: X1 X2 X3 X4 X5 4468 2010-03-24 3 1.000000e+00 1 2 7662 2010-03-24 9 3.000000e+00 2 1 1272 2010-03-25 8 2.000000e+00 1 1 1273 2010-03-26 9 0.000000e+00 1 1 1274 2010-03-27 8 0.000000e+00 1 1 4469 2010-03-28 4 0.000000e+00 1 2 7663 2010-03-28 4 3.000000e+00 3 1 8734 2010-03-28 7 4.000000e+00 2 3 1275 2010-03-29 8 0.000000e+00 1 1 As you can see the first column contains a date. What I want to do is as follows: I want to transform this dataframe to a new one "DF2" where there is only 1 row per date with corresponding column values: X2, the average X3, the sum X4, the maximum of all previous values per date. X5 is not relevant and can be removed. This would be the result: X1 X2 X3 X4 7662 2010-03-24 6 4.000000e+00 2 1272 2010-03-25 8 2.000000e+00 1 1273 2010-03-26 9 0.000000e+00 1 1274 2010-03-27 8 0.000000e+00 1 8734 2010-03-28 5 7.000000e+00 3 1275 2010-03-29 8 0.000000e+00 1 Does anyone know how to accomplish this? Help would be much appreciated!
Tags (comma-separated)
Save Edits
Cancel