向 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