This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmd = "google-chrome https://www.iptorrents.com/t" | |
subprocess.getstatusoutput(cmd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
fig, axes = plt.subplots(10,2, # 10行,2列 | |
sharex=True, sharey=True, # X、Y轴共享刻度 | |
figsize=(2*6, data_len*8)) # 设定图大小,注意是整个图片大小,而不是每个子图的大小 | |
for i in range(10): | |
axes[i, 0].scatter(data[i,:,0], data[i,:,1]) | |
axes[i, 1].scatter(predict_data[i,:,0], predict_data[i,:,1]) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# @Time : 2019/12/18 10:36 | |
# @Author : wangchong | |
# @Email: chongwangcc@gmail.com | |
# @File : es_example.py | |
# @Software: PyCharm | |
from configparser import ConfigParser | |
from elasticsearch import Elasticsearch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
print(sys.version) | |
from pyspark.sql import SparkSession | |
# Python3.8的例子--GPU机器本地运行,取消下面的注释 | |
# import os | |
# os.environ["PYSPARK_PYTHON"] = "/usr/local/bin/python3.8" | |
spark = SparkSession\ | |
.builder\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -* | |
from __future__ import print_function | |
import httplib2 | |
import os | |
from apiclient import discovery | |
from oauth2client import client | |
from oauth2client import tools | |
from oauth2client.file import Storage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# @Time : 2019/1/22 7:19 | |
# @Author : wangchong | |
# @Email: chongwangcc@gmail.com | |
# @File : DateTools.py | |
# @Software: PyCharm | |
from datetime import datetime, timedelta | |
import calendar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1 循环 sleep | |
from datetime import datetime | |
import time | |
# 每n秒执行一次 | |
def timer(n): | |
while True: | |
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S")) | |
time.sleep(n) | |
# 5s | |
timer(5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df1 = pandas.DataFrame( { | |
"Name" : ["Alice", "Bob", "Mallory", "Mallory", "Bob" , "Mallory"] , | |
"City" : ["Seattle", "Seattle", "Portland", "Seattle", "Seattle", "Portland"] } ) | |
""" | |
其中打印时显示为: | |
City Name | |
0 Seattle Alice | |
1 Seattle Bob | |
2 Portland Mallory | |
3 Seattle Mallory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
data = pd.DataFrame({'id':[1,1,1,2,2,2],'value':['A','B','C','D','E','F']}) | |
data1 = data.groupby(by='id')['value'].sum() | |
""" | |
输出结果 | |
id | |
1 ABC | |
2 DEF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list.sort(cmp=None, key=None, reverse=False) | |
aList = [123, 'Google', 'Runoob', 'Taobao', 'Facebook']; | |
aList.sort(); |