![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
泥鳅812
这个作者很懒,什么都没留下…
展开
-
win10下使用conda安装tensorflow的gpu版本
【代码】win10下使用conda安装tensorflow的gpu版本。原创 2023-05-04 17:28:20 · 325 阅读 · 0 评论 -
pypi & condaforge
pypi & condaforge原创 2023-03-09 01:24:51 · 161 阅读 · 0 评论 -
python精确的四舍五入
python实现准确的四舍五入原创 2022-11-18 17:57:06 · 343 阅读 · 0 评论 -
.condarc配置
conda换源原创 2022-11-03 23:40:55 · 1486 阅读 · 0 评论 -
windows全局激活conda(包括cmd,powershell,pycharm)
## 首先基本conda和python路径配置好,环境变量: ## 截图1## pycharm:## 截图2## cmd:# 替换初始启动命令行即可,截图3cmd.exe /k "call C:\InstallPackages\anaconda3\Scripts\activate.bat C:\InstallPackages\anaconda3 " ## anaconda路径## powershell: conda init powershell ## 创建运行powershell原创 2022-01-12 01:28:16 · 1285 阅读 · 0 评论 -
两数交换(不引入第三变量,不数字越界)
## 原来写法(java)int temp = arr[i];arr[i] = arr[j];arr[j] = temp;数学方法,先加后减arr[j + 1] = arr[j + 1] + arr[j];arr[j] = arr[j + 1] - arr[j];arr[j + 1] = arr[j + 1] - arr[j];数学方法,先减后加arr[j + 1] = arr[j] - arr[j + 1];arr[j] = arr[j] - arr[j + 1];arr[j +原创 2021-08-12 17:23:28 · 102 阅读 · 0 评论 -
CNN之image2column
import numpy as npimport numba@numba.jit(nopython=False, parallel=True)def im2col(input_data, filter_h, filter_w, stride=1, pad=0): N, C, H, W = input_data.shape out_h = (H + 2*pad - filter_h)//stride + 1 out_w = (W + 2*pad - filter_w)//s.原创 2021-02-26 18:12:24 · 416 阅读 · 0 评论 -
elasticsearch简单操作
es操作查看索引:curl -X GET 'localhost:9200/_cat/indices?v&pretty'查看节点:curl -X GET 'localhost:9200/_cat/nodes?v&pretty'创建索引:curl -X PUT 'localhost:9200/customer?pretty&pretty'删除索引curl -X DELETE 'localhost:9200/customer?pretty&pretty'.原创 2021-02-03 11:05:55 · 117 阅读 · 0 评论 -
tensorflow2.x使用cuda10.2(非常简单)
# 目前tensorflow2.2官方标配cuda10.1,也是官方在github给出方案,修改cuda软链接即可,非常简单。# 前提是你已经正确安装cuda10.2,检查:nvidia-sminvcc -V# 干正事(重点就这一步):cd /usr/local/cuda-10.2/targets/x86_64-linux/lib/ln -s libcudart.so.10.2.89 libcudart.so.10.1# 检查是否可用:source /etc/profile>原创 2020-06-17 15:05:20 · 21846 阅读 · 23 评论 -
lightgbm(gpu)在linux(centos7)安装
#保证gpu是正常可用的:nvidia-sminvcc -V#进入root权限,且python环境为你正常使用环境,比如anaconda3,而不是python2.7#首先进行必要的升级:#cmake>=3.2(eg: v3.16.8)#https://cmake.org/download/./configuremakemake install#boost>=1.56(eg: v1.61)#https://dl.bintray.com/boostorg/release/原创 2020-07-03 11:19:07 · 989 阅读 · 2 评论 -
python必装包
pip installscipy numba numpy pandas pandas_profiling dask mpi4pypyarrow pyspark pymysql pymongo redis redisclustermatplotlib seaborn pyecharts plotlynltk jieba snownlpscikit-learn statsmodels pr...原创 2020-04-21 11:47:40 · 979 阅读 · 2 评论 -
python--raise Exception
def printError(v): if v: pass else: raise Exception('Not exiests `V`.')原创 2018-02-04 22:33:09 · 11189 阅读 · 0 评论 -
python--for...else...,while...else...
for i in range(5): print(i) #breakelse: print('else?')s = [1,2,3]while s: print(s.pop()) #breakelse: print('else?')待填坑。。。原创 2018-02-04 22:38:48 · 152 阅读 · 0 评论 -
stochastic VS random
random With random process, the same probability is assigned to all outcomes because each outcome has an equal chance of occurring. Typical examples of random processes include drawing a card from a...原创 2018-03-16 05:12:59 · 1282 阅读 · 0 评论 -
python 排序
import numpy as npprint(np.argmax(xx), np.argmin(xx)) # 最大值索引值mm = np.arange(10)np.random.shuffle(mm) # 随机打乱mm的顺序# mm = array([5, 6, 3, 9, 8, 2, 4, 0, 7, 1])print(np.sort(mm), mm.sort())print...原创 2018-03-10 19:58:44 · 167 阅读 · 0 评论 -
pyspark参数设置,常用时间函数
spark-submit --master yarn-client --num-executors 8 --driver-memory 4g --executor-memory 2g spark_demo.py原创 2018-08-16 16:39:11 · 3008 阅读 · 0 评论 -
python 日期为昨天
# method 1:import arrowyesterday = arrow.utcnow().to('local').shift(days=-1).format('YYYY-MM-DD')print(yesterday,type(yesterday))# output:# 2018-02-01 <class 'str'># method 2:import da...原创 2018-02-02 13:47:59 · 362 阅读 · 0 评论 -
python迭代对象降维
迭代对象降维至一维:# coding=utf-8from collections import Iterabledef oneDim(L): for each in L: if not isinstance(each, Iterable) or isinstance(each,str): #保护单词不被拆成一个个字母 yield each原创 2018-01-26 07:03:45 · 385 阅读 · 0 评论 -
python3--map,reduce,filter,zip
# coding=utf-8pool1 = [1,2,3,4]pool2 = ['a','b','c','d']## map()r1 = list(map(lambda x: x*2,pool1))print(r1) #[2, 4, 6, 8]## reduce()from functools import reducer2 = reduce(lambda x,y: x*y,原创 2018-01-06 09:52:27 · 226 阅读 · 0 评论 -
xgboost关于python(anaconda)最简安装(*unix,win)
1、*unix: pip install xgboost or anaconda search -t conda xgboost conda install py-xgboost ,conda install -c aterrel xgboost , …2、windows: conda install conda install -c mndrake xgboost orgit cl原创 2017-12-29 23:35:27 · 512 阅读 · 0 评论 -
spark在windows安装
spark在windows安装原创 2017-12-28 16:41:03 · 2812 阅读 · 3 评论 -
pandas与numpy数据结构互相转化
pandas与numpy数据结构互相转化转载 2017-12-18 00:33:36 · 3191 阅读 · 0 评论 -
python豆瓣源及模块更新
python国内豆瓣源 豆瓣:https://pypi.doubanio.com/simple/pip3 install -i https://pypi.doubanio.com/simple/ seleniumeasy_install -i https://pypi.doubanio.com/simple/ selenium原创 2017-08-25 18:00:54 · 2113 阅读 · 1 评论 -
一口气安装完keras,tensorflow,pytorch,opencv
环境:anaconda4.2;python3.5;windows10,64,cuda先前辛苦的cuda9.1无用,大家想用gpu一定要选cuda8.0,我以为官方会相应的更新,naive!首先tensorflow不认,再者cudnn自家都不认,只有8.0。keras和tensorflow都是pip,pytorch和opencv都是去找whl。关于keras的backend和安装tensorflow时原创 2017-12-31 03:00:27 · 2747 阅读 · 0 评论 -
python OneHotEncoder()
X = OneHotEncoder().fit_transform(X_data).todense() #one-hot编码原创 2018-03-18 05:05:05 · 2550 阅读 · 0 评论 -
python 求导数
from sympy import *x = Symbol("x")diff(x**3+x,x)#output: 3*x**2 + 1# 一维多项式操作from numpy import poly1d原创 2018-03-13 04:54:13 · 33273 阅读 · 0 评论 -
安装pytorch (win10)
conda install -c anaconda mklconda install -c peterjc123 pytorch-cpu##后续会有Windows官方的pytorch。原创 2018-04-08 19:41:48 · 238 阅读 · 0 评论 -
ahalei_25.26
克拉兹问题是一个简单有趣而又没有解决的数学问题。这个问题是由L. Collatz在1937年提出的。 问题如下: (1)输入一个正整数n; (2)如果n=1则结束; (3)如果n是奇数,则n变为3n+1,否则n变为n/2; (4)转入第(2)步。 举一个例子:n=13的时候,经历10步可以达到1。 13 -> 40 -> 20 -> 10 -> 5 -> 16 ->原创 2017-03-06 19:02:27 · 344 阅读 · 0 评论 -
用pyspark的方式写count(case when)
import pyspark.sql.functions as fnff = lambda cond: fn.countDistinct(fn.when(cond,df['s_id']).otherwise(None)cond = (df['class_status']=='FINISHED') & (df['finish_type']=='AS_SCHEDULED')df.gro...原创 2019-09-04 15:59:24 · 3729 阅读 · 0 评论 -
pysaprk求max
#column:A,B# Method 1: Use describe()float(df.describe("A").filter("summary = 'max'").select("A").collect()[0].asDict()['A'])# Method 2: Use SQLdf.registerTempTable("df_table")spark.sql("SELECT...原创 2019-06-05 16:17:13 · 165 阅读 · 0 评论 -
pyspark中"and"条件使用注意
def getLevel(ltv): return fn.when((lv >= 6.81) & (lv <= 10.00),'S')\ .otherwise( fn.when((lv >= 6.08) & (lv < 6.81),'A')\ .otherwise( fn.when((l...原创 2019-04-29 16:50:26 · 1596 阅读 · 0 评论 -
kafka-python_&&_pysparkStreamingContext
# coding=utf-8from pyspark import SparkContextfrom pyspark.streaming import StreamingContextsc = SparkContext("yarn","stream_test")ssc = StreamingContext(sc,1)# monitor: nc -lk 9999lines = ...原创 2019-03-26 18:21:50 · 401 阅读 · 0 评论 -
pyspark&pandas之字符串筛选dataframe
#pandas:import numpy as npimport pandas as pddf = pd.DataFrame(np.array([['banana',1],['apple',2],['pear',3]]).reshape(3,2))df.columns = ['a','b']df2 = df[df['a'].str.contains('l')]print(df2)...原创 2019-02-23 06:15:45 · 3091 阅读 · 0 评论 -
matplotlib_linux作图_时间序列
df21 = data[(data['review_type']=='video') &amp;amp;amp; (data['high_review']==1)]df22 = data[(data['review_type']=='video') &amp;amp;amp; (data['high_review']==0)]fig2 = plt.figure()ax2 = fig2.add_subplot(1,1,1)...原创 2019-01-14 17:19:04 · 321 阅读 · 0 评论 -
pyspark,pandas,sql之分组排序
import pyspark.sql.functions as fnfrom pyspark.sql import Windowdf.withColumn("row_number", fn.row_number().over(Window.partitionBy("id").orderBy(df["pt"].desc()))).show()原创 2018-12-19 15:57:01 · 3448 阅读 · 0 评论 -
pyspark_dataframe
from __future__ import division,print_functionimport timeimport datetimeimport numpy as npimport pandas as pdfrom pyspark import SparkContext,SparkConffrom pyspark.sql import SparkSession,Column...原创 2018-09-17 20:24:50 · 397 阅读 · 0 评论 -
python 判断汉字
def is_chinese(uchar): """判断一个unicode是否是汉字""" if uchar >= u'\u4e00' and uchar<=u'\u9fa5': return True else: return False原创 2018-05-22 11:11:44 · 9752 阅读 · 1 评论 -
日期格式化
python中时间日期格式化符号: %y 两位数的年份表示(00-99) %Y 四位数的年份表示(000-9999) %m 月份(01-12) %d 月内中的一天(0-31) %H 24小时制小时数(0-23) %I 12小时制小时数(01-12) %M 分钟数(00=59) %S 秒(00-59) %a 本地简化星期名称 %A 本地完整星期名称 %...转载 2018-05-21 14:42:55 · 389 阅读 · 0 评论 -
tensorflow,keras安装(py35,win10)
pip install --upgrade --ignore-installed tensorflowpip install --upgrade --ignore-installed tensorflow-gpu以上为shit! 他会影响整体conda包的版本兼容性(3.5.2与3.5.4),故安装tensorflow需要新建环境。首先建一个c:\tensorflow-lib 然后conda原创 2017-12-31 00:33:12 · 656 阅读 · 0 评论 -
最大公约数、最小公倍数
最大公约数、最小公倍数def gcd(n_big, n_small): '''The greatest common divisor func.''' return bcd(n_small, n_big % n_small) if n_big % n_small > 0 else n_smalldef lcm(n_big, n_small): '''The lowest co原创 2017-02-24 23:03:18 · 204 阅读 · 0 评论