• 行,列单元格


    import pandas as pd 
    d = {'x':100,'y':200,'z':300}
    s1 =pd.Series(d)
    print(s1.values) #dic转化为series
    ----------------------------------------------
    [100 200 300]

      

    import pandas as pd
    L1= [100,200,300]
    L2= ['x','y','z']
    
    s1= pd.Series(L1,index= L2)
    print(s1)
    
    ----------------------------------------------
    
    x    100
    y    200
    z    300
    dtype: int64
    

      

    import pandas as pd
    s1 = pd.Series([1,2,3],index = [1,2,3],name = 'A')
    s2 = pd.Series([10,20,30],index = [1,2,3],name = 'B')
    s3 = pd.Series([100,200,300],index = [1,2,3],name = 'C')
    
    df = pd.DataFrame({s1.name:s1,s2.name:s2,s3.name:s3})
    
    print(df)
    
    
    ------------------------------------------------------------------
    
       A   B    C
    1  1  10  100
    2  2  20  200
    3  3  30  300
    import pandas as pd
    s1 = pd.Series([1,2,3],index = [1,2,3],name = 'A')
    s2 = pd.Series([10,20,30],index = [1,2,3],name = 'B')
    s3 = pd.Series([100,200,300],index = [1,2,3],name = 'C')
    
    df = pd.DataFrame([s1,s2,s3])
    
    print(df)
    
    
    --------------------------------------------
    
         1    2    3
    A    1    2    3
    B   10   20   30
    C  100  200  300
    import pandas as pd
    s1 = pd.Series([1,2,3],index = [1,2,3],name = 'A')
    s2 = pd.Series([10,20,30],index = [1,2,3],name = 'B')
    s3 = pd.Series([100,200,300],index = [2,3,4],name = 'C')
    
    df = pd.DataFrame({s1.name:s1,s2.name:s2,s3.name:s3})
    
    print(df)
    
    -------------------------------------------
         A     B      C
    1  1.0  10.0    NaN
    2  2.0  20.0  100.0
    3  3.0  30.0  200.0
    4  NaN   NaN  300.0
  • 相关阅读:
    516. Longest Palindromic Subsequence最长的不连续回文串的长度
    java之spring之整合ssh-2
    java之spring之整合ssh
    java之spring之spring整合hibernate
    微服务之初了解(一)
    java之spring之scope和autowiring
    java之spring之依赖注入
    java之spring之对象的创建
    java之spring之配置讲解
    asp.net core 系列之静态文件
  • 原文地址:https://www.cnblogs.com/inserence/p/10939862.html
Copyright © 2020-2023  润新知