我有一个数据框,我从中选择了唯一的值,它产生了一个形状的ndarray("unManager")(1187,)......只有一列.
现在,我编写了一个函数来对数据帧的某些行进行分组,进行计算并在ndarray中添加值.
我正在使用ndarray("unManager")上的apply,并收到以下错误:
AttributeError Traceback (most recent call last)
<ipython-input-48-ff7e78ab33a7> in <module>()
----> 1 unManager.apply(runThis, axis=0)
AttributeError: 'numpy.ndarray' object has no attribute 'apply'
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试将ndarray("unManager")转换为数据帧时,通过:
dfs = pd.DataFrame(unManager,index=unManager[0])
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-55-3ee3d2605321> in <module>()
----> 1 dfs = pd.DataFrame(unManager,index=unManager[0])
.
.
TypeError: Index(...) must be called with a collection of some kind, 'actama99,CLE' was passed
Run Code Online (Sandbox Code Playgroud)
'actama99,CLE'这里是形状的ndarray("unManager")的第一个值(1187,).
有人可以告诉我,我做错了什么?TIA
我正在尝试为 nltk.concordance 运行以下代码,但它没有给出任何结果。有人可以指导我我做错了什么吗?
import nltk.corpus
from nltk.text import Text
sent = '''China is an emerging FinTech hotbed thanks to its expanding middle class, rapid digitization and electronic payments adoption. But a new report from Citi found that, while China may be the market to watch for FinTech investments, the U.S. continues to thrive at the top of the B2B FinTech mountain.
According to Digital Disruption — Revisited: What FinTech VC Investments Tells Us About A Changing Industry, Citi expects an …Run Code Online (Sandbox Code Playgroud) 我有一个以下格式的 pandas DataFrame:
df.head()
y y_pred
599 0 0
787 9 9
47 2 2
1237 1 1
1069 6 6
Run Code Online (Sandbox Code Playgroud)
我想找到行/索引号 - 其中 y != y_pred。
我正在努力做到这一点,Select但无法做到。请帮忙。
TIA