import numpy as np
import pandas as pd
frame = pd.DataFrame((np.arange(12) + 1).reshape(4,3),
columns = list('ABC'),
index = [1,2,3,4])
columns2 = list('ABCD')
frame2 = frame.reindex(columns = columns2)
lt = list([13,14,15,16])
frame2.loc[:,'D'] = lt
print(frame2)
結果:
A B C D
1 1 2 3 13
2 4 5 6 14
3 7 8 9 15
4 10 11 12 16