【发布时间】:2017-01-26 16:58:48
【问题描述】:
df1:
lower_bound_ip_address upper_bound_ip_address country
0 16777216.0 16777471 Australia
1 16777472.0 16777727 China
2 16777728.0 16778239 China
3 16778240.0 16779263 Australia
4 16779264.0 16781311 China
df:
ip_address
0 7.327584e+08
1 3.503114e+08
2 2.621474e+09
3 3.840542e+09
4 4.155831e+08
5 2.809315e+09
6 3.987484e+09
7 1.692459e+09
8 3.719094e+09
9 3.416747e+08
我是 python 新手。 我想将 df['ip_address'] 与 df1['country'] 匹配。一定的ip_address范围对应特定的国家,例如:729808896-734003199表示日本。该怎么做?
我写了以下代码,但是有错误。 TypeError: len() of unsized object
for x in df['ip_address']:
if x<=df1['upper_bound_ip_address'] and x>=df1['lower_bound_ip_address']:
df['country']=df1['country']
【问题讨论】:
-
将您的数据框发布为文本而不是 iages,错误是什么
-
TypeError: len() of unsized object
-
将您的数据框发布为文本而不是图像