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
0  Cindy     78   male
1   John     87   male
2   Matt     88   male

你可能感兴趣的:(Pandas,Python)