Python 在DataFrame增加一列相同的数值
生成一个 DataFrame
import pandas as pd name = [‘Cindy‘,‘John‘,‘Matt‘] point = [78,87,88] df_grade = pd.DataFrame(name, columns=[‘name‘]) df_grade = pd.concat([df_grade, pd.DataFrame(point,columns=[‘point‘])],axis=1)
新增一列
df_grade[‘gender‘] = ‘male‘ print(df_grade)
结果
name point gender Cindy 78 male John 87 male Matt 88 male
相关推荐
81510295 2020-11-17
roamer 2020-10-29
listep 2020-09-11
Tristahong 2020-08-24
三石 2020-08-23
QianYanDai 2020-08-16
Johnson0 2020-07-28
mmmjyjy 2020-07-16
santiago00 2020-07-11
QianYanDai 2020-07-05
QianYanDai 2020-07-05
jiahaohappy 2020-06-21
QianYanDai 2020-06-16
Oeljeklaus 2020-05-29
zhangxiaojiakele 2020-05-25
人家 2020-05-17
jzlixiao 2020-05-15
柠檬班 2020-05-16
jiahaohappy 2020-05-12