addresses lats
0 street lat
1 316 36th St NaN
2 1400 Broadway NaN
3 230 5th Ave NaN
4 630 1st Ave 40.7452
5 18 33rd St 40.74814
6 630 1st Ave 40.7452
7 1245 Park Ave 40.78659
8 444 46th St 40.76161
9 132 36th St 40.75145
10 146 29th St 40.74728
11 255 36th St 40.75326
12 1100 Ave of the Americas 40.7550567
13 777 Westchester Ave 41.02749
14 9 57th St 40.76386
15 880 3rd Ave 40.758
我想列出
addresses
具有相应的
nan
在中
lats
柱
给定数据帧的列表为:
['316 13th st, '1400 broadway', '230 5th ave']
.
目前我正在使用以下代码,但它正在创建中所有元素的列表
地址
如前所述,我只想要具有
南
在下一列中。怎样才能有效地做到这一点?
# creating my data frame from the columns
df = pd.read_csv(filename, header = None, error_bad_lines = False, usecols = [9, 28], names =
['addresses', 'lats'])
# converting the addresses column to a list
addresses = df['addresses'].tolist()
# removing any 'nan' from the addresses list (if any exist)
addresses = [x for x in addresses[1:] if str(x) != 'nan']