How to pad leading zeros to the Time column?
up vote
0
down vote
favorite
Using 'df_dropped'
, a data frame, which has a column 'Time'
.
df_dropped['Time'] = df_dropped['Time'].apply(lambda x:'{:0>4}'.format(x))
I don't understand what the '{:0>4}'.format(x)'
does.
Please explain the construction of this line '{:0>4}'.format(x)'
python pandas dataframe data-science
add a comment |
up vote
0
down vote
favorite
Using 'df_dropped'
, a data frame, which has a column 'Time'
.
df_dropped['Time'] = df_dropped['Time'].apply(lambda x:'{:0>4}'.format(x))
I don't understand what the '{:0>4}'.format(x)'
does.
Please explain the construction of this line '{:0>4}'.format(x)'
python pandas dataframe data-science
2
What you are looking for might be answered here: stackoverflow.com/questions/4008546/…
– DMarczak
Nov 13 at 5:22
Possible duplicate of How to pad with n characters in Python
– user3287355
Nov 13 at 5:31
Explained here:- datacamp-global.slack.com/archives/C654VRAJ2/…
– Manideep Pullalachervu
2 days ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Using 'df_dropped'
, a data frame, which has a column 'Time'
.
df_dropped['Time'] = df_dropped['Time'].apply(lambda x:'{:0>4}'.format(x))
I don't understand what the '{:0>4}'.format(x)'
does.
Please explain the construction of this line '{:0>4}'.format(x)'
python pandas dataframe data-science
Using 'df_dropped'
, a data frame, which has a column 'Time'
.
df_dropped['Time'] = df_dropped['Time'].apply(lambda x:'{:0>4}'.format(x))
I don't understand what the '{:0>4}'.format(x)'
does.
Please explain the construction of this line '{:0>4}'.format(x)'
python pandas dataframe data-science
python pandas dataframe data-science
edited Nov 14 at 13:12
asked Nov 13 at 5:15
Manideep Pullalachervu
11
11
2
What you are looking for might be answered here: stackoverflow.com/questions/4008546/…
– DMarczak
Nov 13 at 5:22
Possible duplicate of How to pad with n characters in Python
– user3287355
Nov 13 at 5:31
Explained here:- datacamp-global.slack.com/archives/C654VRAJ2/…
– Manideep Pullalachervu
2 days ago
add a comment |
2
What you are looking for might be answered here: stackoverflow.com/questions/4008546/…
– DMarczak
Nov 13 at 5:22
Possible duplicate of How to pad with n characters in Python
– user3287355
Nov 13 at 5:31
Explained here:- datacamp-global.slack.com/archives/C654VRAJ2/…
– Manideep Pullalachervu
2 days ago
2
2
What you are looking for might be answered here: stackoverflow.com/questions/4008546/…
– DMarczak
Nov 13 at 5:22
What you are looking for might be answered here: stackoverflow.com/questions/4008546/…
– DMarczak
Nov 13 at 5:22
Possible duplicate of How to pad with n characters in Python
– user3287355
Nov 13 at 5:31
Possible duplicate of How to pad with n characters in Python
– user3287355
Nov 13 at 5:31
Explained here:- datacamp-global.slack.com/archives/C654VRAJ2/…
– Manideep Pullalachervu
2 days ago
Explained here:- datacamp-global.slack.com/archives/C654VRAJ2/…
– Manideep Pullalachervu
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
It adds 0 character to each elements of data-frame until it reach 4 character. If the element is more than 4 character will do nothing.
you can see below example:
import pandas as pd
df = pd.DataFrame(data=[23, "fsda", 289801, 87], columns=['Time'], index=[0, 1, 2, 3])
df['Time'] = df['Time'].apply(lambda x: '{:0>6}'.format(x))
'{:0>6}'.format(x) can you explain this bit of code
– Manideep Pullalachervu
Nov 14 at 4:44
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
It adds 0 character to each elements of data-frame until it reach 4 character. If the element is more than 4 character will do nothing.
you can see below example:
import pandas as pd
df = pd.DataFrame(data=[23, "fsda", 289801, 87], columns=['Time'], index=[0, 1, 2, 3])
df['Time'] = df['Time'].apply(lambda x: '{:0>6}'.format(x))
'{:0>6}'.format(x) can you explain this bit of code
– Manideep Pullalachervu
Nov 14 at 4:44
add a comment |
up vote
0
down vote
It adds 0 character to each elements of data-frame until it reach 4 character. If the element is more than 4 character will do nothing.
you can see below example:
import pandas as pd
df = pd.DataFrame(data=[23, "fsda", 289801, 87], columns=['Time'], index=[0, 1, 2, 3])
df['Time'] = df['Time'].apply(lambda x: '{:0>6}'.format(x))
'{:0>6}'.format(x) can you explain this bit of code
– Manideep Pullalachervu
Nov 14 at 4:44
add a comment |
up vote
0
down vote
up vote
0
down vote
It adds 0 character to each elements of data-frame until it reach 4 character. If the element is more than 4 character will do nothing.
you can see below example:
import pandas as pd
df = pd.DataFrame(data=[23, "fsda", 289801, 87], columns=['Time'], index=[0, 1, 2, 3])
df['Time'] = df['Time'].apply(lambda x: '{:0>6}'.format(x))
It adds 0 character to each elements of data-frame until it reach 4 character. If the element is more than 4 character will do nothing.
you can see below example:
import pandas as pd
df = pd.DataFrame(data=[23, "fsda", 289801, 87], columns=['Time'], index=[0, 1, 2, 3])
df['Time'] = df['Time'].apply(lambda x: '{:0>6}'.format(x))
answered Nov 13 at 14:10
saeed heidari
1644
1644
'{:0>6}'.format(x) can you explain this bit of code
– Manideep Pullalachervu
Nov 14 at 4:44
add a comment |
'{:0>6}'.format(x) can you explain this bit of code
– Manideep Pullalachervu
Nov 14 at 4:44
'{:0>6}'.format(x) can you explain this bit of code
– Manideep Pullalachervu
Nov 14 at 4:44
'{:0>6}'.format(x) can you explain this bit of code
– Manideep Pullalachervu
Nov 14 at 4:44
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53274249%2fhow-to-pad-leading-zeros-to-the-time-column%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
What you are looking for might be answered here: stackoverflow.com/questions/4008546/…
– DMarczak
Nov 13 at 5:22
Possible duplicate of How to pad with n characters in Python
– user3287355
Nov 13 at 5:31
Explained here:- datacamp-global.slack.com/archives/C654VRAJ2/…
– Manideep Pullalachervu
2 days ago