Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: update all values(zero padding) #160

Open
coldmu opened this issue Aug 21, 2021 · 3 comments
Open

Question: update all values(zero padding) #160

coldmu opened this issue Aug 21, 2021 · 3 comments

Comments

@coldmu
Copy link

coldmu commented Aug 21, 2021

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 :)

@coldmu coldmu changed the title Question: update all series(zero padding) Question: update all values(zero padding) Aug 21, 2021
@coldmu
Copy link
Author

coldmu commented Aug 21, 2021

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...

@coldmu
Copy link
Author

coldmu commented Aug 21, 2021

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.

@chrmang chrmang self-assigned this Aug 22, 2021
@chrmang
Copy link
Contributor

chrmang commented Aug 22, 2021

Hi coldmu,
it seems to be an unsolved point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants