Python numpy.memap、熊猫数据帧和seaborn箱线图故障

Python numpy.memap、熊猫数据帧和seaborn箱线图故障,python,pandas,numpy,seaborn,memory-mapped-files,Python,Pandas,Numpy,Seaborn,Memory Mapped Files,我正在对几个大数据集(总的来说比我的RAM大得多)进行分析。 为了方便我的工作,我使用numpy.memmap加载数据集(在将它们保存到从断层摄影数据集生成的单个.npy文件之后) 从数据集中提取几个值后,我将这些值收集到一个数据框中。 当我查看这些值时,它们会很好地显示出来(例如通过df.head()) 现在我想用类似于seaborn.boxplot(data=df,x='Treatment',y='Tumor\u Vol',hue='Experiment\u Day')的东西来可视化这些值,

我正在对几个大数据集(总的来说比我的RAM大得多)进行分析。 为了方便我的工作,我使用
numpy.memmap
加载数据集(在将它们保存到从断层摄影数据集生成的单个.npy文件之后)

从数据集中提取几个值后,我将这些值收集到一个数据框中。 当我查看这些值时,它们会很好地显示出来(例如通过
df.head()

现在我想用类似于
seaborn.boxplot(data=df,x='Treatment',y='Tumor\u Vol',hue='Experiment\u Day')
的东西来可视化这些值,但我得到的错误是

ValueError: List of boxplot statistics and `positions` values must have same the length
在我看来,这是由于内存映射的值,因为当我将数据帧保存到CSV文件并从磁盘加载回数据帧时(这是我当前的解决方法),同样的命令也会起作用


因此,由于缺少更好的词汇,有没有一种方法可以取消对映射值的记忆,并将它们作为“真实”值保存到数据帧中?

我遇到了同样的非常奇怪的错误。不过,这只会出现在jupyter笔记本上

我有一个简单的数据框,可以用Swarmlot绘制,但不能用boxplot(在笔记本上,但在终端上使用相同的代码)。这很奇怪,因为其他一些数据帧使用相同的代码绘制得很好

我的数据帧:

    sample  color   right-left  (right-left)/right
0   OPAR19_r1c3     Blue    1   0.000334448
1   OPAR19_r1c3     Green   305     0.255444
2   OPAR19_r1c3     Red     15  0.0205479
3   OPAR19_r2c6     Blue    82  0.028063
4   OPAR19_r2c6     Green   260     0.216847
5   OPAR19_r2c6     Red     14  0.0183246
6   OPAR19_r1c1     Blue    75  0.0251931
7   OPAR19_r1c1     Green   -13     -0.0143488
8   OPAR19_r1c1     Red     10  0.0137741
9   OPAR19_r1c4     Blue    -38     -0.0131579
10  OPAR19_r1c4     Green   117     0.110169
11  OPAR19_r1c4     Red     0   0
12  OPAR19_r1c6     Blue    7   0.00239153
13  OPAR19_r1c6     Green   -3  -0.00295858
14  OPAR19_r1c6     Red     -46     -0.0640669
15  OPAR19_r2c4     Blue    95  0.0315824
16  OPAR19_r2c4     Green   191     0.163668
17  OPAR19_r2c4     Red     36  0.0447761
18  OPAR19_r2c5     Blue    48  0.0164215
19  OPAR19_r2c5     Green   165     0.154639
20  OPAR19_r2c5     Red     -4  -0.00542005
21  OPAR19_r1c5     Blue    199     0.0655468
22  OPAR19_r1c5     Green   262     0.223169
23  OPAR19_r1c5     Red     103     0.141678
24  OPAR19_r1c2     Blue    102     0.0340681
25  OPAR19_r1c2     Green   198     0.179837
26  OPAR19_r1c2     Red     75  0.0955414
27  OPAR19_r2c1     Blue    221     0.0742857
28  OPAR19_r2c1     Green   99  0.108791
29  OPAR19_r2c1     Red     11  0.0147453
30  OPAR19_r2c2     Blue    159     0.0526664
31  OPAR19_r2c2     Green   64  0.0724802
32  OPAR19_r2c2     Red     -21     -0.0276316
33  OPAR19_r2c3     Blue    16  0.00536733
34  OPAR19_r2c3     Green   84  0.0769936
35  OPAR19_r2c3     Red     -49     -0.0639687
此绘图在笔记本上失败,但在python文件上失败

sns.boxplot(data=df_out2,x='color',y='right-left')
以下是错误:

ValueError: List of boxplot statistics and `positions` values must have same the length
虽然使用Swarmlot或stripplot的等效绘图效果良好:

sns.swarmplot(data=df_out2,x='color',y='right-left')

我也遇到过同样的怪癖。不过,这只会出现在jupyter笔记本上

我有一个简单的数据框,可以用Swarmlot绘制,但不能用boxplot(在笔记本上,但在终端上使用相同的代码)。这很奇怪,因为其他一些数据帧使用相同的代码绘制得很好

我的数据帧:

    sample  color   right-left  (right-left)/right
0   OPAR19_r1c3     Blue    1   0.000334448
1   OPAR19_r1c3     Green   305     0.255444
2   OPAR19_r1c3     Red     15  0.0205479
3   OPAR19_r2c6     Blue    82  0.028063
4   OPAR19_r2c6     Green   260     0.216847
5   OPAR19_r2c6     Red     14  0.0183246
6   OPAR19_r1c1     Blue    75  0.0251931
7   OPAR19_r1c1     Green   -13     -0.0143488
8   OPAR19_r1c1     Red     10  0.0137741
9   OPAR19_r1c4     Blue    -38     -0.0131579
10  OPAR19_r1c4     Green   117     0.110169
11  OPAR19_r1c4     Red     0   0
12  OPAR19_r1c6     Blue    7   0.00239153
13  OPAR19_r1c6     Green   -3  -0.00295858
14  OPAR19_r1c6     Red     -46     -0.0640669
15  OPAR19_r2c4     Blue    95  0.0315824
16  OPAR19_r2c4     Green   191     0.163668
17  OPAR19_r2c4     Red     36  0.0447761
18  OPAR19_r2c5     Blue    48  0.0164215
19  OPAR19_r2c5     Green   165     0.154639
20  OPAR19_r2c5     Red     -4  -0.00542005
21  OPAR19_r1c5     Blue    199     0.0655468
22  OPAR19_r1c5     Green   262     0.223169
23  OPAR19_r1c5     Red     103     0.141678
24  OPAR19_r1c2     Blue    102     0.0340681
25  OPAR19_r1c2     Green   198     0.179837
26  OPAR19_r1c2     Red     75  0.0955414
27  OPAR19_r2c1     Blue    221     0.0742857
28  OPAR19_r2c1     Green   99  0.108791
29  OPAR19_r2c1     Red     11  0.0147453
30  OPAR19_r2c2     Blue    159     0.0526664
31  OPAR19_r2c2     Green   64  0.0724802
32  OPAR19_r2c2     Red     -21     -0.0276316
33  OPAR19_r2c3     Blue    16  0.00536733
34  OPAR19_r2c3     Green   84  0.0769936
35  OPAR19_r2c3     Red     -49     -0.0639687
此绘图在笔记本上失败,但在python文件上失败

sns.boxplot(data=df_out2,x='color',y='right-left')
以下是错误:

ValueError: List of boxplot statistics and `positions` values must have same the length
虽然使用Swarmlot或stripplot的等效绘图效果良好:

sns.swarmplot(data=df_out2,x='color',y='right-left')

您可以对感兴趣的数据子集调用
copy
,将其拉入ram。e、 g.
data\u subset=memmap\u data[i:j].copy()
似乎没有帮助,因为
plot\u copy=df.ix[:,['Tumor\u vol','Experiment\u Day','Treatment'].copy()
我仍然得到plot\u copy['Tumor\u vol']中i的类型
。如果你包括一个最小的、完整的、可验证的例子(),我可能能够一起破解一些东西。否则,你很难把你正在尝试的东西和不起作用的东西拼凑起来。我同意如果没有一个不完整的例子,这是非常困难的。我看能否在周一把问题简化成一个完整的例子。有趣的是,当我尝试重新创建它时,问题并没有出现:gist包含一个原始笔记本的精简副本,其中显示了错误和我尝试重新创建它的情况……您只需对感兴趣的数据子集调用
copy
,将其拉入ram。e、 g.
data\u subset=memmap\u data[i:j].copy()
似乎没有帮助,因为
plot\u copy=df.ix[:,['Tumor\u vol','Experiment\u Day','Treatment'].copy()
我仍然得到plot\u copy['Tumor\u vol']中i的类型
。如果你包括一个最小的、完整的、可验证的例子(),我可能能够一起破解一些东西。否则,你很难把你正在尝试的东西和不起作用的东西拼凑起来。我同意如果没有一个不完整的例子,这是非常困难的。我将在周一看看是否可以将问题简化为一个完整的示例。有趣的是,当我尝试重新创建它时,问题并没有出现:摘要包含一份原始笔记本的精简副本,其中显示了错误以及我尝试重新创建它的情况……我实际上意识到这与在笔记本或终端上运行无关。我只是在终端上通过从csv文件加载数据来运行它。因此,如果将我的数据帧保存到csv,然后重新加载,则不会显示错误。这意味着这与数据帧有关,但我不知道这里有什么问题。有什么解决办法吗?我实际上意识到这与在笔记本或终端上运行无关。我只是在终端上通过从csv文件加载数据来运行它。因此,如果将我的数据帧保存到csv,然后重新加载,则不会显示错误。这意味着这与数据帧有关,但我不知道这里有什么问题。有什么解决办法吗?