Pandas 返回数值列中字符串值的行号?

Pandas 返回数值列中字符串值的行号?,pandas,Pandas,我正在尝试将列转换为数字,如果列中的大多数值都是数字,但有些值包含字符串值,则函数应返回包含字符串值的列的行号。 我的数据集: received 11 12 0 -340 2 9 1 aa nn qbb 预期输出:行编号:8,9,10包含字符串值我认为需要使用errors='concurve'进行过滤,以返回NaNs,以返回isnull: i = df.index[pd.to_numeric(df['received'], errors='coerce').isnull()] print (i

我正在尝试将列转换为数字,如果列中的大多数值都是数字,但有些值包含字符串值,则函数应返回包含字符串值的列的行号。 我的数据集:

received
11
12
0
-340
2
9
1
aa
nn
qbb
预期输出:行编号:8,9,10包含字符串值

我认为需要使用
errors='concurve'
进行过滤,以返回
NaN
s,以返回
isnull

i = df.index[pd.to_numeric(df['received'], errors='coerce').isnull()]
print (i)
Int64Index([7, 8, 9], dtype='int64')
python计数从
0
,因此如果需要将其从
1
的计数更改为:

i = df.index[pd.to_numeric(df['received'], errors='coerce').isnull()] + 1
print (i)
Int64Index([8, 9, 10], dtype='int64')
词典使用:

d = df.loc[pd.to_numeric(df['received'], errors='coerce').isnull(), 'received'].to_dict()
print (d)
{8: 'nn', 9: 'qbb', 7: 'aa'}

我能得到带值的行号吗,比如{8:“aa”,9:“nn”}?它给出了一个空格dictionary@Sidhartha-我认为这意味着没有字符串值,只有数字。返回什么
df.loc[pd.to_numeric(df['received'],errors='concurve')。isnull()]