Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将Google Sheets中的两列合并到这个混乱的数据结构中_Python_Python 3.x_Data Structures_Gmplot - Fatal编程技术网

Python 将Google Sheets中的两列合并到这个混乱的数据结构中

Python 将Google Sheets中的两列合并到这个混乱的数据结构中,python,python-3.x,data-structures,gmplot,Python,Python 3.x,Data Structures,Gmplot,我正在从谷歌表单中抽取两列。它们包含横向/纵向信息。我可以用以下代码打印它们: x1 = [item1 for item1 in wks.col_values(3) if item1] for item1 in x1[1:]: print(item1) print(Decimal(item1)) x2 = [item2 for item2 in wks.col_values(4) if item2] for item2 in x2[1:]: print(item2)

我正在从谷歌表单中抽取两列。它们包含横向/纵向信息。我可以用以下代码打印它们:

x1 = [item1 for item1 in wks.col_values(3) if item1]
for item1 in x1[1:]:
    print(item1)
    print(Decimal(item1))

x2 = [item2 for item2 in wks.col_values(4) if item2]
for item2 in x2[1:]:
    print(item2)
    print(Decimal(item2))
输出:

39.204345
39.204345
39.204345
39.204345
39.602555
39.602555
39.802999
39.802999
-76.67478
-76.67478
-76.674806
-76.674806
-76.674822
-76.674822
-76.374822
-76.374822
我如何获得所有这些值和任何未来值以使用这种类型的数据结构

latitude, longitude = zip(*[
    (37.769901, -122.498331),
    (37.768645, -122.475328),
    (37.771478, -122.468677),
    (37.769867, -122.466102),
    (37.767187, -122.467496),
    (37.770104, -122.470436)
])
换句话说,有没有一种方法可以将这两个列拉长和拉长,然后像上面那样将它们拉长?这是用于gmplot的

编辑:其他错误。只有错误。尝试了很多不同的方法

latitude = int(float(wks.col_values(3)))
longitude = int(float(wks.col_values(4)))
##latitude, longitude = np.ndarray(*zip(x1[1:], x2[1:]))

apikey = '' # (your API key here)
gmap = gmplot.GoogleMapPlotter(37.766956, -122.448481, 14, apikey=apikey)
gmap.scatter(latitude, longitude, color='#FF0000', size=75, marker=False)
gmap.draw('newmap.html')



TypeError: float() argument must be a string or a number, not 'list'

看到
x1
x2
具有相同的长度,您可以说:

latitude, longitude = zip(*[(x1[i], x2[i]) for i in range(1,len(x1) - 1)])
或者,您可以使用切片表示法,而不必担心长度:

latitude, longitude = zip(*zip(x1[1:], x2[1:]))

嗯,你知道怎么解决这个问题吗?:在get_cycle lat1=(math.pi/180.0)*lat TypeError:不能用“float”
tuple([math.pi*x/180.0代表lat中的x])类型的非整数乘以序列。
我建议你检查numpy。numpy.ndarray数组以您尝试的方式工作;它将每个元素乘以浮点值,并返回另一个ndarray类型的对象和相应的编码结果。此外,发生错误的原因是解释器建议您可能要将序列(在本例中为元组)复制整数次(例如当3*“hey”给您“HeyHey”时,只有在这种情况下,序列才是字符串)但它发现了一个浮动。我相信您想要将degs转换为rads,所以我建议使用numpy!刚刚被更疯狂的错误淹没:ValueError:int()的无效文本,以10为底:'-72.942747'C_C