Daily Average/Mean Using GroupBy #666
Unanswered
ZandercraftGames
asked this question in
Q&A
Replies: 2 comments
-
I changed my code slightly to run this: console.log(surveyFile.dtypes)
let grp = surveyFile.groupby(["DATE"])
console.log(grp.groups)
console.log(grp)
const avgs = grp.agg({SPEED: "mean", LENGTH: "sum"})
avgs.print()
console.log(avgs)
console.log(avgs.dtypes) And it returns the following for sums:
Still Seems like it's trying to concat the strings or do addition operations on strings without maintaining the proper types. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Some kinda sketchy workarounds, not sure what exactly did it, but this worked: const copy = surveyFile.copy();
copy.addColumn(
"SPEED",
surveyFile["SPEED"].values.map((v: string) => {
const num = Number(v);
return isNaN(num) ? null : num;
}),
{ inplace: true }
);
const formatted2 = copy.dropNa({ axis: 1, inplace: false })
let grp = formatted2.groupby(["DATE"])
const dailyAvgDF = grp.agg({SPEED: "mean"})
dailyAvgDF.print() Still clearly something funky going on with the loss of type. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm currently having an issue with getting a daily average grouped by date (a standardized string object - no need for datetime type here).
This results in a dataframe of
["DATE", "SPEED_mean"]
which is what I expect, but for some reason, every value isInfinity
. I don't have any negative or NaN speeds. They are all integer values.Here are my dtypes from
surveyFile
:It seems that the
groupBy
operation converts the numbers to a string type.Seems related to #581 and #544
Beta Was this translation helpful? Give feedback.
All reactions