go-gota / gota

Gota: DataFrames and data wrangling in Go (Golang)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: update all values(zero padding)

coldmu opened this issue · comments

I want to fill zero-padding.
It is not easy to update all values.
Could you help it? plz...


(Before) df:

col1 col2
123 Paul
33 Jane

(After) df:

col1 col2
000123 Paul
000033 Jane

thank you :)

I try to use series.Map().

sel2 := sel1.Col("col1")

zeroFill := func(e series.Element) series.Element {
		result := e.Copy()
		zeroResult := fmt.Sprintf("%06s", result.String())
		result.Set(zeroResult)
		return series.Element(result)
	}

received := sel2.Map(zeroFill)

But I got other problems.. how to change series type.
When I update values, it was removed 0. Because it is still int type...

I found a solution!!
When I got data, I can handle data type with options.

Like this:
cs = dataframe.ReadHTML(strings.NewReader(htmlUTF8), dataframe.DetectTypes(false), dataframe.DefaultType(series.String))[0]

But I'm still curious how to change series type.

Hi coldmu,
it seems to be an unsolved point.