I have to read data from excel and convert it into DataFrame. but rows are of type 2D slice. How can I convert it to corresponding DataFrame?
import (
"fmt"
"github.com/go-gota/gota/dataframe"
"github.com/xuri/excelize/v2"
)
func main() {
f, err := excelize.OpenFile(sheetPath)
if err != nil {
fmt.Print(err)
}
rows, err := f.GetRows(sheetName)
if err != nil {
fmt.Print(err)
}
df := dataframe.LoadRecords(rows, dataframe.HasHeader(true))
}
I'm getting following error:
panic: runtime error: index out of range [1] with length 1
goroutine 1 [running]:
EDIT:
I have 4 columns. I've noticed that the 25th row contains a value only in the first column. When I attempt to create a DataFrame by including up to the 25th row, it works fine. However, when I include the 25th row and try to create a DataFrame, I encounter an 'index out of range' error. I need up to 30 rows to dataframe. Therefore, should I address the issue of empty values before converting the data into a DataFrame?
you can replace the row, which has less cells before converting to a dataframe.