energetic
 1 import pandas
 2 #Series表示序列,可以表示行或者列
 3 
 4 d={\'x\':100,\'y\':300,\'z\':400}
 5 s1=pandas.Series(d)
 6 #print(s1.index)   #查看其中的索引
 7 
 8 s1=pandas.Series([1,2,3],index=[1,2,3],name=\'A\')
 9 s2=pandas.Series([30,50,70],index=[1,2,3],name=\'B\')
10 s3=pandas.Series([20,70,59],index=[1,2,3],name=\'C\')
11 
12 
13 
14 #把三个Series序列当做列
15 df=pandas.DataFrame({s1.name:s1,s2.name:s2,s3.name:s3})
16 print(df)
17 
18     A B   C
19 1   1 30 20
20 2   2 50 70
21 3  3 70  59
22 
23 #把三个Series序列当做行
24 df1=pandas.DataFrame([s1,s2,s3])
25 print(df1)
26 
27   1   2  3
28 A 1   2  3
29 B 30 50 70
30 C 20 70 59

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-06-06
  • 2021-10-17
  • 2021-08-27
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
猜你喜欢
  • 2021-06-17
  • 2021-07-08
  • 2021-08-05
  • 2021-09-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案