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 requests | |
import pandas | |
import copy | |
# 根据公司名或者app_code查询id | |
url = "http://121.5.100.192:7006/api/user_app/get_page" | |
res = requests.post(url=url, json={ | |
"page_size": 1000, | |
"page_num": 1, | |
"like_name": "" |
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
# Save Model Using joblib | |
import pandas | |
from sklearn import model_selection | |
from sklearn.linear_model import LogisticRegression | |
import joblib | |
url = "https://raw.githubusercontent.com/jbrownlee/Datasets/master/pima-indians-diabetes.data.csv" | |
names = ['preg', 'plas', 'pres', 'skin', 'test', 'mass', 'pedi', 'age', 'class'] | |
dataframe = pandas.read_csv(url, names=names) | |
array = dataframe.values | |
X = array[:,0:8] |
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 | |
from pandas.api.types import CategoricalDtype | |
df = pd.DataFrame({ | |
'order_id': [1001, 1002, 1003, 1004, 1005, 1006, 1007], | |
'customer_id': [10, 12, 12, 12, 10, 10, 10], | |
'month': ['Feb', 'Jan', 'Jan', 'Feb', 'Feb', 'Jan', 'Feb'], | |
'day_of_week': ['Mon', 'Wed', 'Sun', 'Tue', 'Sat', 'Mon', 'Thu'], | |
}) |
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 gensim.downloader as api | |
print(api.load('word2vec-google-news-300', return_path=True)) | |
from gensim import models | |
word2vec_path = './word2vec-google-news-300.gz' | |
w2v_model = models.KeyedVectors.load_word2vec_format(word2vec_path, binary=True) | |
print(w2v_model["king"]) |
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
例如,以下的代码是错误的: | |
class Student(object): | |
# 方法名称和实例变量均为birth: | |
@property | |
def birth(self): | |
return self.birth | |
这是因为调用s.birth时,首先转换为方法调用,在执行return self.birth时,又视为访问self的属性, |
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
from collections import Counter | |
Counter([1,1,1,2,3,2,2,]) | |
# 返回字典统计key的个数 | |
Counter(list).most_common() | |
# 常见的几个 | |
from collections import defaultdict | |
nums = defaultdict(int) | |
nums['one'] = 1 | |
nums['two'] = 2 |
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
s=pd.Series([11,12,13],name='S') | |
data=np.arange(21,24) | |
df=pd.DataFrame({'A':[31,32,33],'B':[41,42,43]}) | |
fun=lambda x:x.A+x.B | |
df.assign(C=fun,D=df.A+df.B,E=s,F=data)#增加新列 | |
A B C D E F | |
0 31 41 72 72 11 21 |
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 python3 | |
# -*- coding: utf-8 -*- | |
# @Time : 2020/12/2 4:20 下午 | |
# @File : file_transfer_tools.py | |
import paramiko | |
class FileTransferTool(object): | |
def __init__(self): | |
paramiko.util.log_to_file("./data/paramiko.log") |
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
# sudo apt-get install language-pack-zh* | |
# sudo apt-get install chinese* |
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
geopoint = {'latitude':41.123,'longitude':71.091} | |
print('{latitude} {longitude}'.format(**geopoint)) |
NewerOlder