赞
踩
- import pandas as pd
-
- df = pd.DataFrame(columns = ['A','B','C','D'])
-
- for i in range(4):
-
- s = pd.Series(['A1','B4', 'C4', 'D4'], index=data.columns, name = i)
-
- df = df.append(s, ignore_index=True)
-
-
- print(df)
A B C D
0 A1 B4 C4 D4
1 A1 B4 C4 D4
2 A1 B4 C4 D4
3 A1 B4 C4 D4
- import pandas as pd
-
- df = pd.DataFrame(columns = ['A','B','C','D'])
- index = ['a','b','c','d']
-
- for i in range(4):
- df.loc[index[i]] = ['A'+str(i),'B'+str(i),'C'+str(i),'D'+str(i)]
-
- print(df)
A B C D
a A0 B0 C0 D0
b A1 B1 C1 D1
c A2 B2 C2 D2
d A3 B3 C3 D3
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。