python
天马行空KY
这个作者很懒,什么都没留下…
展开
-
Python正确初始化二维数组
转载:https://www.cnblogs.com/coderzh/archive/2008/05/18/1201993.html Python中初始化一个5 x 3每项为0的数组,最好方法是: multilist=[[0forcolinrange(5)]forrowinrange(3)] 我们知道,为了初始化一个一维数组,我们可以这样做: alist=[0]*5 没错,那我们初始化一个二维数组时,是否可以这样做呢: multi=[[0]*5]*...转载 2020-10-10 11:03:34 · 4792 阅读 · 1 评论 -
Python groupby总结
1、分组排名取第n个 1、先排序后分组 ans_fund_nav = ans_fund_nav.sort_values(by=['KEY1', 'TRADE_DT']).groupby('KEY1') 2、取第一个 ans_fund_nav_st = ans_fund_nav.head(1)[['KEY1', 'VLU']] 2、分组排名用apply函数 ans_fund_nav = ans_fund_nav.sort_values(by=['KEY1', 'TRADE_DT'])\原创 2020-09-11 14:26:10 · 289 阅读 · 0 评论 -
Python的Pandas库与Oracle Sql操作的一一对应关系
1、where sql: select * from c12_prod_hold_summary where position_dt >= 20170704 and position_dt between 20170701 and 20170704 and sk_f_prod in ('pd02170163', 'pd02xyzh08') and secu_type_code not in ('期货', '远期') and account_projec...原创 2020-08-06 11:23:54 · 841 阅读 · 1 评论 -
Hive、Spark、Python实现WordCount
Hive: select word, count(*) from ( select explode(split(sentence, ' ')) as word from article ) t group by word原创 2020-08-27 12:42:47 · 148 阅读 · 0 评论 -
Python通过判断Excel表格数据来移动文件
import os import shutil import xlrd excel_path = r"D:\指标.xlsx" indicator_path = r"D:\IDX_V17" destination_path = r"D:\IDX" # 打开excel表格 excel_wb = xlrd.open_workbook(excel_path) # 打开第一个sheet页 sheet1 = excel_wb.sheet_by_index(0) # 行数减1,行数根据有值的行来确定 rowNum .原创 2020-08-26 17:27:08 · 406 阅读 · 0 评论 -
Python常见报错汇总
1、ImportError: cannot import name 'TcpServer' from 'platforms.action' 原因:版本冲突,sys.path里面有v1.1版本的路径,导致它去找了v1.1版本,而没有找3.0版本 解决方案:查看环境变量的PYTHONPATH或者PATH变量(Administrator和系统变量)是否含有v1.1版本,有的话删除即可。 ...原创 2020-08-05 15:59:59 · 403 阅读 · 0 评论