python CheatSheet

1.google map

import requests

response = requests.get('https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA')

resp_json_payload = response.json()

print(resp_json_payload['results'][0]['geometry']['location'])

 

2. pandas sql

http://www.cnblogs.com/fuxiaotong/p/7802575.html


3. output file

df_output.to_csv("my_predict.csv", index=False, encoding='utf-8')

 

4. dataframe types

df.dtypes

 

5. convert type

df[x].astype(str)

 

6. Plot

1.

radius = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
area = [3.14159, 12.56636, 28.27431, 50.26544, 78.53975, 113.09724]

plt.plot(radius, area)

plt.show()

 

 2.

df.plot(x='date',y='unit_sales')
plt.show()

 

7.dataframe merge

http://blog.csdn.net/zutsoft/article/details/51498026

dfA.append(dfB)

 

posted @ 2017-04-06 12:54  付小同  阅读(487)  评论(0编辑  收藏  举报