GoTa Series shows NaN, but debugger shows values

Viewed 121

I am trying to do some data science magic with golang. To do that I have starting reading in a csv file of names, and the biological gender. I work with Gota as Dataframe framework

I started to calculate a hardvowel score for the name of every entry like this:

hardVowSeries := df.Select("name").Rapply(hardVowels)
hardVowSeries.SetNames("hard Vowel Score")

My hardVowels function looks like this:

func hardVowels(s series.Series) series.Series {
name := s.String()
name = prepName(name)

hardVow1 := float32(strings.Count(name, "p"))
hardVow2 := float32(strings.Count(name, "k"))
hardVow3 := float32(strings.Count(name, "f"))
lengthName := float32(len([]rune(name)))

hardVowScore := (hardVow1 + hardVow2 + hardVow3) / lengthName
return series.Floats(hardVowScore)}

Now when I change the Series type to int it work but it rounds it to ints and therefor the score is zero everytime I need to save the values as floats, therefore I changed the type of the series as well as all the numeric types to float32.

When I run it in the debugger it shows the float values correctly but when I print the Series after the function with Rapply is done it shows that it is all NaN values. I would be happy for any help. Thank you.

0 Answers
Related