随笔分类 -  Python

Life is short, use Python.
摘要:一天的光滑数据 sub = [199.68, 187.16, 173.97, 159.85, 146.92, 135.29, 125.04, 114.86, 105.85, 97.93, 90.6, 84.19, 78.37, 72.85, 68.93, 66.59, 62.19, 58.59, 5 阅读全文
posted @ 2024-07-06 14:53 RainingInMacondo 阅读(79) 评论(0) 推荐(0) 编辑
摘要:思路 1. 对原始数据一阶求导,得到一阶导数数组。 2. 对一阶导数数组求标准差。导数的标准差提供了导数值的波动性,标准差越小,曲线越平滑。 平滑曲线 import numpy as np import matplotlib.pyplot as plt from matplotlib import 阅读全文
posted @ 2024-07-04 19:23 RainingInMacondo 阅读(620) 评论(0) 推荐(0) 编辑
摘要:原始数据 import matplotlib.pyplot as plt from matplotlib import font_manager fname="/usr/local/python3.6/lib/python3.6/site-packages/matplotlib/mpl-data/f 阅读全文
posted @ 2024-07-04 18:27 RainingInMacondo 阅读(12) 评论(0) 推荐(0) 编辑
摘要:构造时序数据 import numpy as np import matplotlib.pyplot as plt # 设置参数 period = 128 num_cycles = 5 total_length = period * num_cycles # 生成周期性信号(正弦波形) np.ran 阅读全文
posted @ 2024-07-04 17:56 RainingInMacondo 阅读(43) 评论(0) 推荐(0) 编辑
摘要:基于asciichartpy import asciichartpy data = [1, 2, 3, 4, 5, 4, 3, 2, 1] chart = asciichartpy.plot(data) print(chart) 基于sparklines import sparklines data 阅读全文
posted @ 2024-07-01 19:01 RainingInMacondo 阅读(13) 评论(0) 推荐(0) 编辑
摘要:1 记录函数执行耗时 1 def timeToRunWithParams(level, param_idx_lst): 2 def inner(func): 3 def wrapper(*args, **kwargs): 4 s_date = datetime.datetime.now() 5 re 阅读全文
posted @ 2022-11-16 11:38 RainingInMacondo 阅读(33) 评论(0) 推荐(0) 编辑
摘要:量化曲线的波动情况,即如何判断曲线是否平滑? # 求导,统计数据波动的次数,跟阈值作比较 def is_fluctuating(series): ets = series[-1][0] raw = [item[1] for item in series if item[0] >= (ets - 86 阅读全文
posted @ 2021-04-15 10:47 RainingInMacondo 阅读(131) 评论(0) 推荐(0) 编辑
摘要:思路: - 取最近两个周期的数据分别做z-score标准化,然后对结果做差,最后在对结果求标准差。 - 比较标准差和1,小于1则是周期性数据。 原始数据 假设周期性是1天,有一条曲线,包含最近两天的时序数据。 import numpy as np import pandas as pd import 阅读全文
posted @ 2021-03-01 20:23 RainingInMacondo 阅读(3218) 评论(0) 推荐(0) 编辑
摘要:Suppressing Stan optimizer printing in Python 1 # from https://stackoverflow.com/questions/11130156/suppress-stdout-stderr-print-from-python-functions 阅读全文
posted @ 2021-02-04 22:44 RainingInMacondo 阅读(461) 评论(0) 推荐(0) 编辑
摘要:今天发现这本书不错: Python Cookbook 3rd Edition Documentation 记下来,后面抽时间学习学习。 学习是一个不断锐化的过程,切忌故步自封。 路漫漫其哀思不断,吾将上下而求索。 2019-09-26@Beijing 阅读全文
posted @ 2019-09-26 20:02 RainingInMacondo 阅读(276) 评论(0) 推荐(0) 编辑
摘要:问题一:一个文件含有5亿行,每行是一个随机整数,需要对该文件所有整数排序。 分治(Divide&Conquer),参考大数据算法:对5亿数据进行排序 对这个一个500000000行的 total.txt 进行排序,该文件大小 4.6G。 每读10000行就排序并写入到一个新的子文件里(这里使用的是快 阅读全文
posted @ 2019-09-20 12:01 RainingInMacondo 阅读(4789) 评论(0) 推荐(1) 编辑
摘要:二分查找 lst = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] def binary_search(lst,item): low = 0 high = len(lst)-1 while low <= 阅读全文
posted @ 2019-09-14 14:24 RainingInMacondo 阅读(316) 评论(0) 推荐(0) 编辑
摘要:ModelForm组件的简单使用 models.py forms.py views.py register.html 阅读全文
posted @ 2019-09-09 17:17 RainingInMacondo 阅读(251) 评论(0) 推荐(0) 编辑
摘要:一、股票数据分析 1. 获取茅台股票数据并存储到本地csv文件 1 Signature: 2 ts.get_k_data( 3 code=None, 4 start='', 5 end='', 6 ktype='D', 7 autype='qfq', 8 index=False, 9 retry_c 阅读全文
posted @ 2019-04-21 15:15 RainingInMacondo 阅读(346) 评论(0) 推荐(0) 编辑
摘要:Numpy 【数组切片】 【布尔值索引】找出数据中大于5的元素 【布尔值索引】 - 找出数组中大于5的偶数元素 - 找出数组中大于5的书 或 偶数 【花式索引(索引位置无规律)】 【数值取整问题】 numpy.modf():把整数和小数分开 numpy.nan numpy.inf numpy.max 阅读全文
posted @ 2019-04-14 22:58 RainingInMacondo 阅读(157) 评论(0) 推荐(0) 编辑
摘要:参考1:http://www.labri.fr/perso/nrougier/teaching/matplotlib/ 参考2:https://matplotlib.org/api/artist_api.html 阅读全文
posted @ 2019-03-22 20:30 RainingInMacondo 阅读(1405) 评论(0) 推荐(0) 编辑
摘要:今天使用 numpy.true_divide 发现个有趣的事情, 下面的代码18、19行如果去掉,就会报下面的 RuntimeWarning RuntimeWarning 加上对除数是否为0的判断就可以了,是不是说明numpy有一个自动检查的过程? 阅读全文
posted @ 2018-09-06 18:14 RainingInMacondo 阅读(250) 评论(0) 推荐(0) 编辑
摘要:折线图示例 画布和子图 柱状图 饼状图 Matplotlib画正弦余弦曲线 K线图 1 pip3.6 install https://github.com/matplotlib/mpl_finance/archive/master.zip 2 3 from mpl_finance import ca 阅读全文
posted @ 2018-08-15 18:59 RainingInMacondo 阅读(501) 评论(0) 推荐(0) 编辑
摘要:numpy基础 定义array array基本运算 卷积运算 random常用操作 array索引 迭代array 合并array 分割array Numpy.copy() Numpy其他 numpy参考:http://pda.readthedocs.io/en/latest/chp4.html P 阅读全文
posted @ 2018-08-12 13:29 RainingInMacondo 阅读(931) 评论(0) 推荐(0) 编辑
摘要:简单移动平均(sma) def moving_average(f_t): if type(f_t) is not np.ndarray: raise TypeError\ ('Expected one dimensional numpy array.') if f_t.shape[1] != 1: 阅读全文
posted @ 2018-08-05 21:36 RainingInMacondo 阅读(890) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示