过滤后如何将新列从数组添加到Vaex数据框?

问题描述

我有数据文件'for-filter.txt'

<div>
  <div ng-repeat="card in cards">
    <li>
      {{card.dscTitulo}}
      {{card.dscSubTitulo}}
    </li>
  </div>
</div>

我正在做的Vaex代码

a,b,c,d
1,2,3,4
2,6,7,8
-1,4
4,5,5
-2,3

我想将列“ e”添加import vaex as vx import numpy as np df_vaex = vx.from_csv('for-filter.txt') df_filter = df_vaex[df_vaex['a'] > 0] df_filter.head() df_filter['e'] = np.repeat("value",3) ,但出现错误

df_filter

我只关心长度为3的数据帧,因为我只是丢弃了无用的行。但是不知何故,Vaex希望我的长度为5。

熊猫中的类似代码应按预期运行

Array is of length 3,while the length of the DataFrame is 3 due to the filtering,the (unfiltered) length is 5. 

解决方法

已解决

import vaex as vx 
import numpy as np
df_vaex = vx.from_csv('for-filter.txt')
df_filter = df_vaex[df_vaex['a'] > 0]
df_filter.head()
df_filter = df_filter.extract()  # add this line to make real dataframe from lazy indexing
df_filter['e'] = np.repeat("value",3)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...