Golang is a powerful programming language that is widely used in the development of large-scale systems. When using golang, mastering the skills of the first n lines of code is essential. By understanding and adeptly using these key codes, developers can more efficiently write clear, reliable programs. In this article, PHP editor Xigua will introduce you in detail the importance of golang to achieve the first n lines, and share some practical tips and suggestions to help you give full play to the advantages of golang. Whether you are a beginner or an experienced developer, you can benefit from it. Let’s take a closer look!
I'm converting my project from python to golang, but I'm stuck on using gota as the equivalent of pandas dataframe.
In pandas, I use df.nlargest(20, ['change']) to extract the highest value from the dataset, but I can't seem to find the equivalent.
I can sort the data using the following
sorted := valuesDf.Arrange(dataframe.RevSort("Change"))
However, I still need a way to select the first 20 rows of data because next I want to calculate the average of this updated dataframe.
I will use the .mean() function to achieve this
Does anyone know a way to select the first 20 rows?
There is no func in the same function. But you can create your own.
sorted := dataframe.arrange( dataframe.sort("change"), )
Here we sort by field.
sub := sorted.Subset([]int{0, 20})
Now we get the top 20 from this sorted dataframe.
The above is the detailed content of golang must reach the first n lines. For more information, please follow other related articles on the PHP Chinese website!