向 DataFrame 新增新行

給定一個 DataFrame:

s1 = pd.Series([1,2,3])
s2 = pd.Series(['a','b','c'])

df = pd.DataFrame([list(s1), list(s2)],  columns =  ["C1", "C2", "C3"])
print df

輸出:

  C1 C2 C3
0  1  2  3
1  a  b  c

讓我們新增一個新行,[10,11,12]

df = pd.DataFrame(np.array([[10,11,12]]), \
        columns=["C1", "C2", "C3"]).append(df, ignore_index=True)
print df

輸出:

   C1  C2  C3
0  10  11  12
1   1   2   3
2   a   b   c