Giter VIP home page Giter VIP logo

Comments (10)

pjebs avatar pjebs commented on May 15, 2024 1

would you like tell how to convert dataframe to gonum dense matrix ?

Can you use SeriesFloat64 to interact with gonum? The float64 slice is exported for that purpose.

and how to use LoadFromCSV(ctx,strings.NewReader(csvStr)),which ctx ,how to define the context.Context

This is a Go question. Not a dataframe question. import context and use context.Background() if you are unsure.

from dataframe-go.

mullerhai avatar mullerhai commented on May 15, 2024

context.Background()

thx,you have tell me the context use ,LoadFromCSV(ctx,strings.NewReader(csvStr))

but dataframe all data convert to gonum dense matrix also has problem
I use dataframe.SeriesFloat64 variable to create Dataframe,like this

var s1 *dataframe.SeriesFloat64 = dataframe.NewSeriesFloat64("day", nil, 1, 2, 3, 4, 5, 6, 7, 8)
var s2 *dataframe.SeriesFloat64 = dataframe.NewSeriesFloat64("day3", nil, 1, 2, 3, 4, 5, 6, 7, 8)

var dfs  *dataframe.DataFrame = dataframe.NewDataFrame(s1,s2)

,but I dont know how to operate dataframe dfs, I check your source code
when you create dataframe ,the input param tyep is [Series Array ]!!! dataframe.NewDataFrame(s1,s2) ,
func NewDataFrame(se ...Series) *DataFrame

but when I want to get dataframe series array ,
series := dfs.Series
then convert series array to dataframe.SeriesFloat64 array , run the program tell me

【dataframe.SeriesFloat64 not implement Series !!!!】 and Series type has not property like values() method to get []float64 array return, oh my god ,
would you like tell me how to convert the dataframe to gonum dense matrix ,please give me some example code ,thx

from dataframe-go.

mullerhai avatar mullerhai commented on May 15, 2024

would you like tell how to convert dataframe to gonum dense matrix ?

Can you use SeriesFloat64 to interact with gonum? The float64 slice is exported for that purpose.

and how to use LoadFromCSV(ctx,strings.NewReader(csvStr)),which ctx ,how to define the context.Context

This is a Go question. Not a dataframe question. import context and use context.Background() if you are unsure.
I write code like this

"""

func series_convert_floatarray( df *dataframe.DataFrame) []float64{
series := df.Series
arr := make([]float64,len(df.Names())*df.NRows())

for _,data :=range  series{
	//this  has error ,data Series type can not convert to  dataframe.SeriesFloat64
	tem_arr := (dataframe.SeriesFloat64)data

	arr = append(arr,tem_arr.Values )
}
return arr

}
"""

then create dense matrix

"""
import "gonum.org/v1/gonum/mat"
arr := series_cov_arr(dfz)
var mars = mat.NewDense(dfz.NRows(),len(dfz.Names()), arr)

"""

from dataframe-go.

pjebs avatar pjebs commented on May 15, 2024

df.Series[0].(*SeriesFloat64).Values

from dataframe-go.

mullerhai avatar mullerhai commented on May 15, 2024

df.Series[0].(SeriesFloat64).Values

dataframe.SeriesFloat64 does not implement dataframe.Series (Append method has pointer receiver)

cant use it

from dataframe-go.

pjebs avatar pjebs commented on May 15, 2024

Try above now

from dataframe-go.

mullerhai avatar mullerhai commented on May 15, 2024

Try above now

ok ,perfect solve it ,thx

from dataframe-go.

mullerhai avatar mullerhai commented on May 15, 2024

I think maybe you need to add one method like this ,maybe convenient the user like me ,these method is base on python pandas ,

func (df *dataframe.DataFrame ) get_row(row int )[]float64{
series := df.Series
arr := make([]float64,0)
for _,data :=range series{
arr =append(arr,data.Value(row).(float64))
}
return arr
}

func ( df *dataframe.DataFrame) series_convert_floatarray() []float64{
series := df.Series
arr := make([]float64,0)
for _,data :=range series{
tem_arr := data.(*dataframe.SeriesFloat64).Values
arr = append(arr,tem_arr...)
}
return arr
}

func ( df *dataframe.DataFrame) convert_dense_matrix(row ,columns){
....}

from dataframe-go.

pjebs avatar pjebs commented on May 15, 2024

Your using the package wrong. Go is not a language you can just start using quickly.

from dataframe-go.

mullerhai avatar mullerhai commented on May 15, 2024

Your using the package wrong. Go is not a language you can just start using quickly.

I know you say ,but I has used java scala python c++ c# in my company project ,first time use golang just want to use machine learning project ,I need numpy pandas instead of in golang ,so do that

from dataframe-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.