python
theITcat
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
合并文件夹内的PDF文件
""" 拼接文件夹内的pdf文件 """ import PyPDF2 as pdf import os import sys from pathlib import PurePath def combine_pdf(source, target): pdf_merge = pdf.PdfFileMerger() total_pages = 0 for file in os.listdir(source): full_file_path = PurePath.jo.原创 2020-11-04 09:49:03 · 228 阅读 · 0 评论 -
python打印进度 不换行
import time for i in range(100+1): print("当前进度" + str(i) + "%", end="\r", flush=True) time.sleep(1)原创 2020-10-30 14:10:55 · 387 阅读 · 0 评论 -
使用python查看文件夹占用情况
""" 计算指定目录大小 """ import os import sys import prettytable as pt import pandas as pd LONGEST_FILE_PATH = 100 def classify_file_directory(path): """ 返回指定path下第一层文件和文件夹绝对路径列表 param: path 文件夹路径 returns: file_list_full: 第一层的文件.原创 2020-10-21 10:56:27 · 833 阅读 · 1 评论 -
windows python更换豆瓣源
在C:\Users\sdf\AppData\Roaming\pip目录下(sdf为用户名)创建pip.ini文件,内容为: [global] timeout = 6000 index-url =http://pypi.douban.com/simple trusted-host = pypi.douban.com 打开命令行,执行pip install pandas ,可以看到下载速度...原创 2019-10-19 15:23:30 · 1050 阅读 · 0 评论 -
pandas中的索引
Tips1: numpy中索引是左闭右开区间 series的索引是闭区间 Tips2: loc 和iloc loc表示用行名和列名进行索引,iloc表示用行号和列号进行索引原创 2019-09-20 21:11:07 · 341 阅读 · 0 评论 -
pandas的reindex方法中的method参数
method参数的作用是最扩展出来部分的缺失值进行插值,对原有部分不作处理。请看例子: 首先初始化一个 6天的数据: date_index = pd.date_range('1/1/2010', periods=6, freq='D') df2 = pd.DataFrame({"prices": [100, 101, np.nan, 100, 89, 88]},index=date_inde...原创 2019-08-30 21:41:54 · 3375 阅读 · 0 评论 -
numpy中的savez
首先新建两个数组 # 新建两个数组 a = np.array([1, 2, 3]) b = np.array([4, 5, 6]) 示例1:使用savez会将传入的对象保存为map的形式。map的key是变量名,value是变量的值。 # 保存数组到本地文件 np.savez('some_array', c=a, d=b) # 从文件中读取数组 arch = np.load("som...原创 2019-08-29 21:52:05 · 2755 阅读 · 0 评论 -
numpy 沿轴向的sum及mean
xarr: ndarray = np.array([[1, 2],[3, 4]]) xarr.sum(axis=1) 沿1轴进行加法运算的过程如下:原创 2019-08-28 22:18:14 · 492 阅读 · 0 评论 -
numpy中的轴及transpose转置
首先我们获得一个二维数组 import numpy as np arr = np.arange(4).resize(2,2) 这个数组是这样的: #转置方法1 显式制定交换的轴 arr.transpose((1,0)) #转置方法2 省略交换轴的参数 arr.transpose() #转置方法3 arr.T 以上三种方法都将得到arr数组的转置: 数组的转置其实...原创 2019-08-22 23:32:16 · 1207 阅读 · 0 评论 -
numpy通用函数,赋值给自身以及强制类型转换
arr = np.array([0.,1,2,3,4,5,6,7]) np.sqrt(arr, arr) print(arr) sqrt中的两个参数表示:将对于第一个参数的计算结果赋值给第二个参数。 上文中的例子,输出结果为:[0. 1. 1.41421356 1.73205081 2. 2.23606798 2.44948974 2.64575131] 这时就有两个问题,即: 1...原创 2019-08-23 22:34:12 · 2080 阅读 · 0 评论
分享