1 Star 0 Fork 13

MasterGuo/pandas

forked from 王布衣/pandas 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
dataframe_csv_test.go 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2024-02-18 15:25 . dataframe适配series
package pandas
import (
"bytes"
"encoding/json"
"fmt"
"strings"
"testing"
)
func TestCsv(t *testing.T) {
csvStr := `
Country,Date,Age,Amount,Id,close
"United States",2012-02-01,50,112.1,01234,1.231111
"United States",2012-02-01,32,321.31,54320,1.232222
"United Kingdom",2012-02-01,17,18.2,12345,1.233333
"United States",2012-02-01,32,321.31,54320,1.234444
"United Kingdom",2012-02-01,NA,18.2,12345,1.235555
"United States",2012-02-01,32,321.31,54320,1.236666
"United States",2012-02-01,32,321.31,54320,1.237777
Spain,2012-02-01,66,555.42,00241,1.23
`
df := ReadCSV(strings.NewReader(csvStr))
fmt.Println(df)
filename := "./testfiles/test-tutorials-w01.csv"
_ = df.WriteCSV(filename)
buf := new(bytes.Buffer)
_ = df.WriteCSV(buf)
df = ReadCSV(filename)
fmt.Println(df)
_ = df.SetNames("a", "b", "c", "d", "e", "f")
fmt.Println(df)
//s1 := df.Col("d")
//fmt.Println(s1)
//
closes := df.Col("d")
ma5 := closes.Rolling(5).Mean()
//dframe.NewSeriesV2(closes, dframe.Float32s, "")
fmt.Println(ma5)
d := df.Col("d")
fmt.Println(d)
_ = csvStr
}
type T1 struct {
X []int64 `json:"x"`
}
func TestEwm(t *testing.T) {
//a := make(map[string][]int, 8)
t01 := map[string]int64{
"x": 1,
}
fmt.Println(t01)
t02 := map[string][]int64{
"x": {1, 2, 3, 4, 5, 6, 7, 8, 9},
}
fmt.Println(t02)
text := `{"x":[1,2,3,4,5,6,7,8,9]}`
reader := strings.NewReader(text)
parser := json.NewDecoder(reader)
var t1 T1
a1 := parser.Decode(&t1)
fmt.Println(a1, t1)
var t2 map[string][]int
a2 := parser.Decode(&t2)
fmt.Println(a2, t2)
df := ReadCSV(reader)
fmt.Println(df)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/guowujun/pandas.git
git@gitee.com:guowujun/pandas.git
guowujun
pandas
pandas
master

搜索帮助