小编Mic*_*lly的帖子

返回最接近用户定义数字的数据框中的行

我有一个用户定义的数字,我想与数据帧的某一列进行比较.

我想返回一个数据帧的行,它包含(在df的某一列中,比如df.num)与给定数字x最接近的5个数字.

任何关于没有循环的最佳方法的建议将非常感激.

python python-2.7 pandas

17
推荐指数
1
解决办法
1万
查看次数

Pandas列出了数据框中的理解

如果满足某些条件,我想在当前存储在(行+ 1)的第二天打开价格并将其存储在新列中.

df['b']=''

df['shift']=''

df['shift']=df['open'].shift(-1)

df['b']=df[x for x in df['shift'] if df["MA10"]>df["MA100"]]
Run Code Online (Sandbox Code Playgroud)

dataframe python-2.7 pandas

6
推荐指数
1
解决办法
9552
查看次数

.ix上的按位运算(Pandas)

为什么开发人员不允许在.ix上进行按位操作?好奇这是技术约束还是我忽视的逻辑问题.

df.ix[df["ptdelta"]<=0 & df["ptdelta"]>5]
Run Code Online (Sandbox Code Playgroud)

追溯是:

TypeError: ufunc 'bitwise_and' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule 'safe'
Run Code Online (Sandbox Code Playgroud)

"""

:由于熊猫v0.20中,.ix 索引器已被弃用赞成.iloc/ .loc.

dataframe python-2.7 pandas

3
推荐指数
1
解决办法
1724
查看次数

标签 统计

pandas ×3

python-2.7 ×3

dataframe ×2

python ×1