I've been attempting to add a percent sign to a column in my dataframe but to no avail. Would anyone have any idea?
import pandas as pd
names = ('jimmy', 'red', 'julie', 'brad', 'oranges')
score = (82, 38 , 55, 19, 33)
df = pd.DataFrame({'Name': names, 'Grade': score})
df
Out[20]:
Grade Name
0 82 jimmy
1 38 red
2 55 julie
3 19 brad
4 33 oranges
I've made numerous attempts but nothing seems to work out. Here is one failed attempt:
df['Percent'] = str(df['Grade']) + '%'
df['Percent']
Out[22]:
0 0 82
1 38
2 55
3 19
4 33
N...
1 0 82
1 38
2 55
3 19
4 33
N...
2 0 82
1 38
2 55
3 19
4 33
N...
3 0 82
1 38
2 55
3 19
4 33
N...
4 0 82
1 38
2 55
3 19
4 33
N...
Name: Percent, dtype: object
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…