将索引长度与循环中的列表长度匹配

时间:2019-07-16 15:57:59

标签: python pandas csv

我有一个想要随着列表的扩展而扩展的DataFrame。

df['IPS'] = pd.Series(ip)
df[date] = pd.Series(countfreq(re.findall( r'[0-9]+(?:\.[0-9]+){3}', str(
print (df)

列表ip会展开,但设置列时不会显示新元素。它保持与第一次传入(19)相同的长度

0    127.15.20.191           2
1     64.255.65.13           2
2   175.248.78.182           2
3     37.83.22.114           1
4    33.68.135.110           2
5   101.124.127.56           2
6    236.32.91.121           2
7   207.229.230.76           2
8    90.16.136.130           2
9     64.199.43.58           2
10   127.15.20.191           2
11    64.255.65.13           2
12  175.248.78.182           2
13   33.68.135.110           2
14  101.124.127.56           2
15   236.32.91.121           2
16  207.229.230.76           2
17   90.16.136.130           2
18    64.199.43.58           2

例如,如果列表的长度更改为20

0    127.15.20.191           2
1     64.255.65.13           2
2   175.248.78.182           2
3     37.83.22.114           1
4    33.68.135.110           2
5   101.124.127.56           2
6    236.32.91.121           2
7   207.229.230.76           2
8    90.16.136.130           2
9     64.199.43.58           2
10   127.15.20.191           2
11    64.255.65.13           2
12  175.248.78.182           2
13   33.68.135.110           2
14  101.124.127.56           2
15   236.32.91.121           2
16  207.229.230.76           2
17   90.16.136.130           2
18    64.199.43.58           2
19    64.210.89.88           1

0 个答案:

没有答案