Skip to content

Instantly share code, notes, and snippets.

View Everfighting's full-sized avatar
😁
I may be slow to respond.

蔡大锅 Everfighting

😁
I may be slow to respond.
View GitHub Profile
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": ""
# 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]
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'],
})
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"])
例如,以下的代码是错误的:
class Student(object):
# 方法名称和实例变量均为birth:
@property
def birth(self):
return self.birth
这是因为调用s.birth时,首先转换为方法调用,在执行return self.birth时,又视为访问self的属性,
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
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
@Everfighting
Everfighting / file_transfer_tools
Created December 3, 2020 02:16
file transfer to server
#!/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")
@Everfighting
Everfighting / gist:0fa4bae87b9dcaf1fdcde46ceeb1b9ef
Created December 2, 2020 09:34
Installing Asian Fonts on Ubuntu & Debian
# sudo apt-get install language-pack-zh*
# sudo apt-get install chinese*
geopoint = {'latitude':41.123,'longitude':71.091}
print('{latitude} {longitude}'.format(**geopoint))