Menambahkan kolom baru ke DataFrame yang ada di panda menggunakan metode CONCAT
# import pandas library
import pandas as pd
# create pandas DataFrame
df = pd.DataFrame({'team': ['India', 'South Africa', 'New Zealand', 'England'],
'points': [10, 8, 3, 5],
'runrate': [0.5, 1.4, 2, -0.6],
'wins': [5, 4, 2, 2]})
# print the DataFrame
print(df)
# create a new DataFrame
df2 = pd.DataFrame([[1, 2], [2, 1], [3, 4], [0, 3]],
columns=['matches_left', 'lost'])
# concat and Print the new DataFrame
print(pd.concat([df, df2], axis=1))
Gorgeous Gazelle