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)'
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))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.