随笔分类 - Python基础
摘要:%%timeit stgg=np.where(df['close']>df['open'],df['close'],df['open']) stdd=np.where(df['close']<df['open'],df['close'],df['open']) #196 µs ± 1.72 µs p
阅读全文
摘要:How to calculate df.cummin() piecewise I want to start df.cummin() when cond column is true until recompute df.cummin() next cond column is true. The
阅读全文
摘要:%%timeit def compare(A, B): x = A[0] out = [] for a,b in zip(A,B): if b>x: out.append(True) x = a else: out.append(False) return out df['compare'] = c
阅读全文
摘要:ipython中查看代码执行时间的魔法命令 %time: 在行模式下,代码运行一次所花费的时间。%%time:在单元模式下,代码运行一次所花费的时间。 %timeit: 在行模式下,执行代码块若干次,取最佳结果。%%timeit: 在单元模式下,执行代码块若干次,取最佳结果。 PyCharm里效率测
阅读全文
摘要:1&1 #返回1为真 1&0 #返回0为假 1|1&0 #返回1,优先级 &高于| 1>0|2>3 #返回False,优先级 比较运算低于位运算 (1>0)|(2>3) #返回True,有位运算时,比较运算一定要用括号括起来 ~True #返回-2为假 ~False #返回-1为真 ~(3>4)|(
阅读全文
摘要:代码如下 import time import pandas as pd import numpy as np df = pd.DataFrame(np.random.random((100000,3)), columns = ['A', 'B', 'C']) start = time.clock(
阅读全文
摘要:python中没有其他语言中的三元表达式,不过有类似的实现方法 其他语言中,例如java的三元表达式是这样 int a = 1; String b = ""; b = a > 1? "执行表达式1":"执行表达式2" System.out.println(b) 在python中只有类似的替代办法,如
阅读全文
摘要:我有一个带有时间的数组(列表),现在我需要确定该Eclipse的时间是否在此列表的两个连续时间之间。 duurSeq=[11,16,22,29] nu = time.time() verstreken_tijd = nu - starttijd for t in duurSeq: if (verst
阅读全文
摘要:Pandas的loc和iloc的使用 pandas中loc的几种用法 iloc[ ]函数(Pandas库) 如何在pandas中使用loc、iloc函数进行数据索引(入门篇)
阅读全文
摘要:import matplotlib.pyplot as plt plt.figure(figsize=(12,8), dpi=80) plt.plot([1,2,6,4],[4,5,6,9]) plt.show() import matplotlib.pyplot as plt data.plot(
阅读全文
摘要:从官方介绍的历史版本看mplfinance是从0.11.x版2019年12月20日开始更新频繁的,之前的0.10.x版最近的更新在2016年,那么说这个新模块的取代刚刚不到半年的时间,从论坛上搜索资料还比较少。mplfinance与mpl_finance功能相近但是区别还是很大的,之前的candle
阅读全文
摘要:ImportError: cannot import name ‘Feature‘ from ‘setuptools 查阅相关文档发现是setuptool版本的问题,python3源中的setuptools已经升级到46以上,所以导致pip安装失败。解决方案,更新setuptools版本 pip i
阅读全文
摘要:Python库的路径是 \Lib\site-packages pip命令安装 pip install 库名 添加镜像源 pip install 库名 -i https://pypi.tuna.tsinghua.edu.cn/simple 安装指定版本 pip install 库名==版本号 源码安装
阅读全文
摘要:新版本的安装指南(英文教程) https://catalyst-team.github.io/catalyst/getting_started/quickstart.html 新版本的github地址 https://github.com/catalyst-team/catalyst 下面是网上流传
阅读全文
摘要:一、背景 实现某个目录下所有文件(包含子目录中的文件)的列出,可以使用 Python 实现。 二、实现 方法一 # 修改工作目录 import os os.chdir(r'C:\Users\Hider\Desktop') # 定义函数 def list_all_files(rootdir): imp
阅读全文