Im converting my project from Python to Golang but Im stuck in regards to using Gota as an equivalent to Pandas dataFrame.
In Pandas I used df.nlargest(20, ['Change']) to extract the top highest values from my data set but I can't seem to find an equivalent.
I can use the following to sort the data
sorted := valuesDf.Arrange(dataframe.RevSort("Change"))
but still, I need a way to select the top 20 rows of data because next I want to calculate the Mean average for this updated dataFrame.
Which I will use the .Mean() function to achieve this
Does anyone know of a way to select the top 20 rows?
CodePudding user response:
There is no func in the same function. But you can create your own.
sorted := dataframe.Arrange(
dataframe.Sort("Change"),
)
Here we sort by a field.
sub := sorted.Subset([]int{0, 20})
Now we get the top 20 from this sorted dataframe.