![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python3
文章平均质量分 95
qq_43355847
python
展开
-
python计算方法耗时装饰器
def calcMethodsTimes(func): def inner(*args, **kwargs): start = pd.datetime.now() res = func(*args, **kwargs) end = pd.datetime.now() print("methods: %s ,运行共计耗时: %s s"%(func.__name__, end - start)) return res .原创 2020-05-19 15:19:21 · 642 阅读 · 0 评论 -
python pandas 多线程(携程)写入excel
不知道如何优化,写入excel文件依然很慢.# -*- coding: utf-8 -*-## python 3.6.7# Description: # Author: zzq# Date: 2020/4/27import mathimport threadpoolimport asyncioimport pandas as pddef ...原创 2020-04-27 18:06:03 · 3915 阅读 · 2 评论 -
pandas输出excel文件添加表头标题,样式装饰器
以下装饰器将输出带有样式的excel文件。import osimport pandas as pdfrom xlsxwriter.utility import xl_rangedef decoratorToExcel(excel_name: str = "test", excel_title: str = "test", excel_dir: str = None): "...原创 2020-04-22 21:43:19 · 10590 阅读 · 0 评论 -
python多线程学习
理解不深,先这样!# -*- coding: utf-8 -*-# usr/bin/python3.6.7# @idea :PyCharm # @FileName :moreTh.py# @Time :2020/1/2 10:59# @Author :zzqimport timefrom threading import Thread, Lockfr...原创 2020-01-02 12:17:43 · 101 阅读 · 0 评论 -
Python 多进程文件共享变量。
# -*- coding: utf-8 -*-# usr/bin/python3.6.7# @idea :PyCharm # @FileName :moreThread.py# @Time :2019/12/31 16:12# @Author :zzqimport timeimport osfrom multiprocessing import Pro...原创 2019-12-31 18:07:17 · 257 阅读 · 0 评论 -
关于pandas多级表头,输出Excel文件空白行问题
找到pandas源码文件excel.py函数起始大概在源码551行,贴上源码 函数_format_regular_rows def _format_regular_rows(self): has_aliases = isinstance(self.header, (tuple, list, np.ndarray, Index)) if has_alia...原创 2019-12-04 13:30:26 · 5289 阅读 · 4 评论 -
pandas 多级表头
df.columns.get_level_values(0).values# 索引层级从0开始返回一个listdf.columns.to_list()# 返回一个 [(), (), ()]原创 2019-11-13 19:10:23 · 9801 阅读 · 0 评论 -
分享一款pycharm / intellij好看的主题。(python和java)
如图传送门提取码:us7v原创 2019-05-31 10:03:33 · 3672 阅读 · 1 评论 -
记录一次读取 9.8G的一个csv文件,并且写入mysql。
记录一次读取1600万 行 X 41列的csv文件。目标 /环境文件数据为测试模拟数据,数据大小 9.8G,目标为读取数据,并且写入mysql。目标文件运行环境:python3.6 (64位),pandas,pymysql。思路采用pandas内置read_csv方法,分块读取文件,开4个进程写入mysql。遇到的坑有,memoryerror,这里需要强调!!! 必须把写入过的数...原创 2019-05-26 21:17:54 · 752 阅读 · 3 评论 -
python @property动态属性方法记录。
原始代码。这里获取一个学生的年龄,我们定义get_age 方法。要获取年龄需要student.get_age()代码如下。from datetime import date, datetimeclass Students: def __init__(self, name, birthday): self.name = name self.birthday = birth...原创 2019-05-19 18:53:09 · 344 阅读 · 0 评论 -
pandas全表查询,根据条件返回。记录一次爬坑过程。
关于pandas的查询,深深的掉了一个大坑。以此来记录一下不知道元素在那一列,哪一行,先上一个坑。t1 =time.clock()for id in ids:#id为需要查找的元素 for indexs in df1.index:#循环行 for i in range(len(df1.loc[indexs].values)):循环行内元素 ...原创 2019-03-27 22:47:09 · 1665 阅读 · 0 评论 -
pyqt5显示sql数据
代码pip install sqlalchemy from sqlalchemy import create_engineself.engine = create_engine('mysql+pymysql://root:root123@localhost/test')#创建一个全局i连接sql = ' SELECT * FROM job51'input_table = pd.read_...原创 2019-03-08 09:50:38 · 4068 阅读 · 0 评论 -
pyqt5 +pyinstall打造属于自己的桌面版程序(学习阶段)
网上关于pyqt5的教程特别少,终于东拼西凑,做出一点东西出来,很简单的小应用,便于上手学习。pyqt5的主文件代码如下,代码特别多,也没怎么细分。大家可以参考下。github地址pyinstall打包的一点小技巧送给大家。取消生成程序doc窗口使用命令pyinstaller -F -i 图标路径 文件路径 --noconsole(取消dos)如果生成的应用有图片文件,可...原创 2019-03-07 23:42:20 · 738 阅读 · 0 评论 -
pandas备忘(二)
关于pandas的透视表的用法import pandas as pd import numpy as np df = pd.DataFrame({'ID':['01','02','01','03','01'], "code":['A','A','B','C','D'], 'descrit':['一号','二号','三号','四号','五号'], 'score':[85,76,80,5...原创 2019-03-09 19:10:43 · 206 阅读 · 0 评论