Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/310.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 如何使用谷歌地图地理位置创建数据帧?_Python_Pandas_Google Maps_Google Geolocation - Fatal编程技术网

Python 如何使用谷歌地图地理位置创建数据帧?

Python 如何使用谷歌地图地理位置创建数据帧?,python,pandas,google-maps,google-geolocation,Python,Pandas,Google Maps,Google Geolocation,在Python 3和Pandas中,我有一个带有地址的数据帧: import pandas as pd consolidado = pd.read_excel('empresas_de_seguranca_consolidado_final.xlsx', converters={'cnpj': lambda x: str(x)} ) consolidado.info() <class 'pandas.core.frame.DataFrame'> RangeIndex: 1226

在Python 3和Pandas中,我有一个带有地址的数据帧:

import pandas as pd

consolidado = pd.read_excel('empresas_de_seguranca_consolidado_final.xlsx', converters={'cnpj': lambda x: str(x)} )

consolidado.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1226 entries, 0 to 1225
Data columns (total 25 columns):
cnpj                                1226 non-null object
CNAE_principal                      1136 non-null object
nome_empresa                        1226 non-null object
nome_empresa_maiuscula_minuscula    1001 non-null object
estado                              1001 non-null object
indicador                           1147 non-null float64
documento                           1147 non-null object
qualificacao                        1147 non-null object
socio                               1150 non-null object
socio_maiuscula_minuscula           1004 non-null object
data_abertura                       1218 non-null object
logradouro                          1155 non-null object
numero_logradouro                   1155 non-null object
complemento                         646 non-null object
cep                                 938 non-null object
bairro                              1206 non-null object
municipio                           1226 non-null object
regiao                              231 non-null object
telefone                            764 non-null object
email                               344 non-null object
situacao                            1226 non-null object
data_situacao_baixa                 434 non-null object
capital_social                      856 non-null object
cargo_relacionado_socio             190 non-null object
observacao                          327 non-null object
dtypes: float64(1), object(24)
memory usage: 239.5+ KB
将熊猫作为pd导入
consolidado=pd.read_excel('empresas_de_seguraca_consolidado_final.xlsx',converters={'cnpj':lambda x:str(x)})
consolidado.info()
范围索引:1226个条目,0到1225
数据列(共25列):
cnpj 1226非空对象
CNAE_主体1136非空对象
nome_empresa 1226非空对象
nome_empresa_maiuscula_minuscula 1001非空对象
estado 1001非空对象
指示符1147非空浮点64
documento 1147非空对象
Qualificao 1147非空对象
非空对象
Social_maiuscula_Minscula 1004非空对象
data_abertura 1218非空对象
logradouro 1155非空对象
numero_logradouro 1155非空对象
互补646非空对象
cep 938非空对象
bairro 1206非空对象
市政1226非空对象
regiao 231非空对象
telefone 764非空对象
电子邮件344非空对象
situacao 1226非空对象
数据_situacao_baixa 434非空对象
capital_social 856非空对象
cargo_relacionado_非空对象
observacao 327非空对象
数据类型:float64(1),object(24)
内存使用:239.5+KB
完整地址由“logradouro”(街道、大道等)、“numero_logradouro”(地名)、“Completo”(地址补充)、“bairro”(街道)和“市政”(城市)列组成

例如,地址“R AURELIO VALPORTO,51岁,里约热内卢MARECHAL HERMES LOJA A”,创建链接:

请问,我是否可以访问谷歌地图API(谷歌街景)发送这些完整的地址,并接收每个地址的财产和链接的图像以及地址的更多地理位置(纬度和经度)

我的目的是用这些数据创建一个数据框,如果可能的话,创建一个包含图像下载的文件夹。地址来自巴西

我找到了这个解决方案:

import googlemaps
import google_streetview.api

# Insert your key
gmaps = googlemaps.Client(key='')

# Geocoding an address
geocode_result = gmaps.geocode('R JORGE RUDGE, 108, CASA 23, VILA ISABEL, RIO DE JANEIRO')

lat = geocode_result[0]['geometry']['location']['lat']
lng = geocode_result[0]['geometry']['location']['lng']

# Define parameters for street view api
params = [{
  'size': '600x300', # max 640x640 pixels
  'location': str(lat)+","+str(lng),
  'heading': '0;90;180;270',
  'pitch': '-0.76',
  'key': '' # insert
}]

# Create a results object
results = google_streetview.api.results(params)

# Download images to directory 'downloads'
results.download_links('downloads')