Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 带有熊猫系列对象的海生地块_Python_Pandas_Statistics_Seaborn - Fatal编程技术网

Python 带有熊猫系列对象的海生地块

Python 带有熊猫系列对象的海生地块,python,pandas,statistics,seaborn,Python,Pandas,Statistics,Seaborn,我有4个熊猫系列对象,它们大小不同,索引也不同。我想创建一个条形图或箱线图来显示这些序列的中值是如何不同的 e、 g我的系列之一是: 0.912 1.4324 2.3910 1.4324 5.2331 另一个: 2.1231 3.4244 4.123 我无法将seaborn.boxplot或seaborn.barplot设置为可视化如下内容:与数据帧和一起使用,然后进行绘图: s1 = pd.Series([1,2,3]) s2 = pd.Series([20,1,3,6,90], inde

我有4个熊猫系列对象,它们大小不同,索引也不同。我想创建一个条形图或箱线图来显示这些序列的中值是如何不同的

e、 g我的系列之一是:

  • 0.912
  • 1.4324
  • 2.3910
  • 1.4324
  • 5.2331
  • 另一个:

  • 2.1231
  • 3.4244
  • 4.123
  • 我无法将seaborn.boxplot或seaborn.barplot设置为可视化如下内容:

    与数据帧和一起使用,然后进行绘图:

    s1 = pd.Series([1,2,3])
    s2 = pd.Series([20,1,3,6,90], index=list('abcde'))
    s3 = pd.Series([4,5,2.6], index=list('ABC'))
    s4 = pd.Series([7,20.8], index=list('XY'))
    
    df = (pd.concat([s1, s2, s3, s4], axis=1, keys=('a','b','c','d'))
            .stack()
            .rename_axis(('a','b'))
            .reset_index(name='c'))
    print (df)
        a  b     c
    0   0  a   1.0
    1   1  a   2.0
    2   2  a   3.0
    3   A  c   4.0
    4   B  c   5.0
    5   C  c   2.6
    6   X  d   7.0
    7   Y  d  20.8
    8   a  b  20.0
    9   b  b   1.0
    10  c  b   3.0
    11  d  b   6.0
    12  e  b  90.0
    
    sns.barplot(data=df, x='b', y='c')
    
    与此类似,并通过以下方式删除缺少的值:

    s1 = pd.Series([1,2,3])
    s2 = pd.Series([20,1,3,6,90], index=list('abcde'))
    s3 = pd.Series([4,5,2.6], index=list('ABC'))
    s4 = pd.Series([7,20.8], index=list('XY'))
    
    
    df = pd.concat([s1, s2, s3, s4], axis=1, keys=('a','b','c','d')).melt().dropna()
    print (df)
       variable  value
    0         a    1.0
    1         a    2.0
    2         a    3.0
    21        b   20.0
    22        b    1.0
    23        b    3.0
    24        b    6.0
    25        b   90.0
    29        c    4.0
    30        c    5.0
    31        c    2.6
    45        d    7.0
    46        d   20.8
    
    sns.barplot(data=df, x='variable', y='value')