
python
三枚目
这个作者很懒,什么都没留下…
展开
-
[python]pandas常用
读csv文件test1.csvmesh,pop1,2002,3003,400test2.csv1,2002,3003,400import pandas as pd#会从第一行开始读数据df = pd.read_csv('test2.csv', header=None,names=["mesh","pop"])#会把csv的第一行认为是header,数据从第二行开始d...原创 2019-04-02 10:00:40 · 382 阅读 · 0 评论 -
[python]发送slack消息
import slackwebslack = slackweb.Slack( url="??????")# 方法1attachments = []attachment = { "pretext": "Email Validation failed", "title": "Email address:", "text": "apsvvfb",}attachments.append(attachment)# 方法2attachments = [ {.原创 2021-09-21 16:23:27 · 1004 阅读 · 0 评论 -
[python][redshift]用python获取redshift中的数据
import psycopg2hostname=xxxxxpw=xxxxxcon=psycopg2.connect(dbname='dynamicpop', host=hostname,port='15439', user='root', password=pw)#con=psycopg2.connect(dbname='dynamicpop', host='localhost',port...原创 2019-11-19 11:37:04 · 1487 阅读 · 0 评论 -
[python]打日语
#-*-coding:utf-8-*-import matplotlib.font_manager as fmfonts = fm.findSystemFonts()i=0print(fonts)print("")for f in fonts: font = fm.FontProperties(fname=f) print(i) print(fonts[i])...原创 2019-11-01 16:19:14 · 627 阅读 · 0 评论 -
[python]读入日语文件
https://stackoverflow.com/questions/147741/character-reading-from-file-in-pythonhttps://stackoverflow.com/questions/19699367/unicodedecodeerror-utf-8-codec-cant-decode-byte>>> file -I t_cit...原创 2019-01-10 16:34:40 · 2568 阅读 · 0 评论 -
[python]调试
ipdb / pdbhttps://xmfbit.github.io/2017/08/21/debugging-with-ipdb/ipdb.set_trace()test.pyimport ipdbif __name__ == "__main__" x = 1 y = 2 ipdb.set_trace() print x+y命令式python -m ipdb test.p...原创 2019-01-24 17:57:07 · 151 阅读 · 0 评论 -
[python]conda python2和python3
mac已经安装了python$$ python --version$$ Python 2.7.5一直在用python2, 说是未来python 主流是python 3,所以就安装一个吧。首先安装condahttps://www.anaconda.com/download/#macos下载下来双击安装打开terminal, 输入Conda list会看到已经安装的包,然后我看到了...原创 2019-01-30 14:46:00 · 2143 阅读 · 0 评论 -
[python]发邮件
在发邮件之前,在本机上配好smtpsend_mail.pyimport argparseimport smtplibfrom email.MIMEMultipart import MIMEMultipartfrom email.MIMEText import MIMETextfrom argparse import RawTextHelpFormatterif __name__ ==...原创 2019-02-13 10:35:59 · 201 阅读 · 0 评论 -
[python]matplotlib存多图
draw(data1,data2,fig): fig = plt.gcf() #get current figure plt.clf() #清除figure上之前画的图 plt.plot(data1,linewidth='5') plt.plot(data2,'r') fig.savefig("abc.png", dpi=200,bbox_inches = 't...原创 2019-03-01 10:50:31 · 236 阅读 · 0 评论 -
[python]时间序列预测
https://blog.youkuaiyun.com/ZVAyIVqt0UFji/article/details/81784639周期时间序列的预测(有python代码)具有周期性特征的序列需要将周期性特征提取出来。python里面的statsmodels工具包里面有针对周期性分解的函数seasonal_decompose,我们可以将序列进行分解。seasonal_decompose这个函数里面...原创 2019-02-22 19:25:21 · 5219 阅读 · 0 评论 -
[python]多个python版本下的pip安装问题
在服务器上python --version显示是python2.7.5但是用pip install statsmodels以后,会被安装到/usr/lib/python3.6/site-packages下,查了一下https://stackoverflow.com/questions/2812520/pip-dealing-with-multiple-python-version...原创 2019-03-04 10:56:31 · 534 阅读 · 0 评论 -
[python]常用总结
splitting bumpy array based on valuehttps://stackoverflow.com/questions/38277182/splitting-numpy-array-based-on-valueimport numpy as npfrom itertools import groupbyb = np.array([ 1, 1, 100, 1...原创 2019-06-12 14:36:06 · 173 阅读 · 0 评论 -
[python]matplotlib/seaborn 画图时日语显示问题(Mac,python2.x)
https://openbook4.me/sections/1674https://qiita.com/akiya3/items/0c8d365cbdafabb5b0dadownload fonthttps://ipafont.ipa.go.jp/node26下载以后,双击ttf文件即可安装(ipaexg.ttf,ipaexm.ttf)pythonpythonPython 2....原创 2019-01-10 16:20:45 · 1023 阅读 · 0 评论 -
[python]逻辑回归
http://dblab.xmu.edu.cn/blog/logistic-regression-in-python/原文2015年的,写的特别详细!!!====================本文基于yhat上Logistic Regression in Python,作了中文翻译,并相应补充了一些内容。本文并不研究逻辑回归具体算法实现,而是使用了一些算法库,旨在帮助需要用Python来做...转载 2018-12-12 11:04:20 · 473 阅读 · 0 评论 -
c++调用Python [boost::python]
安装python安装boost(1) Download boost_1_60_0.tar.bz2. (2) 解压 tar –bzip2 -xf /path/to/boost_1_60_0.tar.bz2 (3) ./bootstrap.sh –with-libraries=python –prefix=/work/na/install/boost –with-python-r原创 2016-03-09 14:21:16 · 2602 阅读 · 1 评论 -
[caffe]extract feature
记得最开始看caffe的时候就在纠结train_val.prototxt 和deploy.prototxt到底有啥区别, 今天要用别人的一个模型提特征, 网站上(https://staff.fnwi.uva.nl/p.s.m.mettes/index.html#data)提供的是caffe model 和 deploy.prototxt, 查了一下午到底怎么提…deploy.prototxtnam原创 2016-06-08 18:27:42 · 4209 阅读 · 1 评论 -
[python]image(reshape,overlay)
import sysimport numpy as np#import scipy.miscfrom scipy import ndimage, miscfrom PIL import Imageimgpath="demo_img1.jpg"#1.generate Attention Map#files=["word.txt","phrase.txt","question.txt"]转载 2016-10-13 16:58:27 · 2523 阅读 · 0 评论 -
[http]get,post
web API: https://labs.goo.ne.jp/api/jp/morphological-analysis/import requests r = requests.post(‘https://labs.goo.ne.jp/api/morph‘, json={“app_id”:”4a875765817519b8e0ced23710a146d60f617e5b0d5a44e7109转载 2016-09-28 09:31:49 · 327 阅读 · 0 评论 -
[python]画图
generalimport sysimport numpy as np import matplotlibmatplotlib.use('Agg') from matplotlib.pyplot import plot,savefigimport matplotlib.pyplot as pltdef isfloat(value): try: float(value)原创 2016-11-21 10:12:55 · 560 阅读 · 0 评论 -
[python]unicode,utf8
I’m reading a json file by python.[ { "id": 1, "qas": [ { "image_id": 1, "qa_id": 10000000, "answer": "グレー", "a_objects": [], "question": "右側の男性は原创 2017-02-15 20:15:29 · 479 阅读 · 0 评论 -
[python][lua]在python里调用Lua
https://stackoverflow.com/questions/30841738/run-lua-script-from-pythonYou can use a subprocess to run your Lua script and provide the function with it’s arguments.import subprocessresult = subprocess.转载 2017-10-27 13:33:03 · 1632 阅读 · 1 评论 -
python,lua,bash
传递参数python [test.py]import sysdataset=sys.argv[1]fea=sys.argv[2]python test.py lcd2012/data/ 1torch[test.lua]a=arg[1]b=arg[2]th test.lua acd 1bash [test.sh]#!/bin/basha=$1b=$2./test.sh 123 stringp原创 2016-11-14 15:11:15 · 1526 阅读 · 1 评论 -
[python] read file
read a txt file and remove \n and punctuationsdes_path="event_description/"for i in range(21,41): des_txt = "%s/E0%d.txt" %(des_path, i) with open(des_txt, 'r') as f: d原创 2017-12-02 15:00:09 · 500 阅读 · 0 评论 -
[tsubame]python[AssertionError: Cannot find installation of real FFmpeg]
job.sh#bin/bash#qsub -g tga-shinoda ./1_genShot.shinfile=/gs/hs0/tga-xx/xx/annotationFiles/Train-6988-shuffleout_dir=/gs/hs0/tga-xx/xx/videoshot_iccv/shotFramesFFMPEG_PATH=/gs/hs0/tga-xx-deep/xx/libr原创 2017-11-24 20:13:03 · 2273 阅读 · 1 评论 -
[python]多元回归
pandasstatsmodelshttps://www.statsmodels.org/stable/regression.html除了下面代码用的ols(最小二乘法以外),还有OLS(endog[, exog, missing, hasconst]) A simple ordinary least squares model.GLS(endog, exog[, sigma, miss...原创 2018-12-12 15:35:49 · 1162 阅读 · 1 评论 -
[python] pool
http://forlinux.blog.51cto.com/8001278/1423390from multiprocessing import Poolapply 开启多个进程并发执行apply_async 同上,但是这个是异步的,非阻塞的。map 类似于内建函数map,后面提供的参数列表会一个一个应用于函数,。这里会开发多个进程并发一起执行。map_async 和map相同,只不过这是一个异步转载 2016-03-04 10:16:07 · 1211 阅读 · 0 评论