
python
SCU-JJkinging
加油,leego must be dai
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
1024拿个勋章
1024程序员节拿个勋章,嘻嘻!!!原创 2021-10-24 18:57:54 · 161 阅读 · 1 评论 -
JSON大文件格式化
在pycharm下方的Terminal中输入命令:python -m json.tool input-file.json output-file.json即可格式化完成!!!原创 2021-08-11 10:33:58 · 1052 阅读 · 1 评论 -
pandas将多张excel表的数据合成一张表
#!/usr/bin/env python# -*- coding: utf-8 -*-# @Time : 2021/3/24 21:21# @Author : JJkinging# @File : test.pyimport pandas as pdimport osdef get_manyExcel_to_one(source_path, res_path): ''' description: 将多张excel表的数据纵向合成一张表 :param s原创 2021-03-24 22:31:36 · 962 阅读 · 0 评论 -
fileinput.FileInput () 读取文件时设置 ‘utf-8’ 编码方式
fileinput.FileInput(读取的文件路径名,openhook=fileinput.hook_encoded('utf-8', ''))))原创 2021-03-14 15:47:02 · 2071 阅读 · 0 评论 -
pandas中的ExcelWriter和ExcelFile
pandas中的ExcelWriter和ExcelFile转载 2021-01-19 15:35:06 · 428 阅读 · 0 评论 -
pd.read_excel()和 pd.to_excel() 参数详解
pandas.read_excel(io,sheet_name = 0,header = 0,names = None,index_col = None,usecols = None,squeeze = False,dtype = None, ...)io:字符串,文件的路径对象。sheet_name:None、string、int、字符串列表或整数列表,默认为0。字符串用于工作表名称,整数用于零索引工作表位置,字符串列表或整数列表用于请求多个工作表,为None时获取所有工作表。值对应操原创 2021-01-19 15:32:59 · 17082 阅读 · 0 评论 -
如何在pandas中使用set_index( )与reset_index( )设置索引
如何在pandas中使用set_index( )与reset_index( )设置索引转载 2021-01-18 20:19:32 · 393 阅读 · 0 评论 -
python的缓存装饰器lru_cache的作用
import functools@functools.lru_cache(None)def add(x, y): print(x, '+', y, '=', end='') return x+yprint(add(1,2))print(add(2,3))print(add(1,2))print(add(4,6))print(add(1,2))print(add(4,6))输出:1 + 2 =32 + 3 =534 + 6 =10310可以看到,反复调用相原创 2020-10-05 14:47:13 · 765 阅读 · 0 评论 -
from collections import defaultdict 的用法
转自 https://blog.youkuaiyun.com/dpengwang/article/details/79308064 认识defaultdict:当我使用普通的字典时,用法一般是dict={},添加元素的只需要dict[element] =value即,调用的时候也是如此,dict[element] = xxx,但前提是element字典里,如果不在字典里就会报错,如: 这时defaultdict就能排上用场了,defaultdict的作用是在于,当字典里的...转载 2020-09-25 11:01:41 · 2121 阅读 · 0 评论 -
python的itertools的chain和combinations函数
1.chain()from itertools import chaina = [1,2,3]b = ['a','b','c']for i in chain(a,b): print(i)输出:1,2,3,a,b,cchain()函数的作用就是可以将任意类型的迭代对象组合起来一起迭代,而不必写两个循环。2.combinations()from itertools import combinationstest_data = (1,2,3,4)for i in combinat原创 2020-09-25 10:52:25 · 759 阅读 · 0 评论 -
python的map()和reduce()函数区别
咱们先从定义上来解释一下这两个函数的区别:①从参数方面来讲:map(func, *iterables)包含两个参数,第一个是参数是一个函数,第二个是序列(列表或元组)。其中,函数(即map的第一个参数位置的函数)可以接收一个或多个参数。reduce(function, sequence[, initial]) 第一个参数是函数,第二个是 序列(列表或元组)。但是,其函数必须接收两个参数。②从对传进去的数值作用来讲:map()是将传入的函数依次作用到序列的每个元素,每个元素都是独自被函数“作用”一次转载 2020-08-18 11:35:24 · 343 阅读 · 0 评论 -
解决python使用pip安装下载库出现错误:ERROR:Cannot unpack file xxxx情况
解决python使用pip安装下载库出现错误:ERROR:Cannot unpack file xxxx情况 以scipy库下载安装为例,在命令行中直接输入命...转载 2020-08-17 11:37:33 · 4456 阅读 · 2 评论 -
解决UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0xbe in position 3: ordinal not in range(128)
最近在做stackGAN的实验时,需要读取预训练的birds的text embedding的pickle文件,遇到UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xbe in position 3: ordinal not in range(128),相关读取代码如下:import pickletext_embedding = open('D://google下载/birds/train/char-CNN-RNN-embeddings.pickl原创 2020-08-09 22:07:51 · 1362 阅读 · 0 评论 -
python的filter() 函数
filter() 函数是python内置的一个高阶函数filter(function or None, iterable) --> filter object它接收一个函数也可以不接收(置为None)和一个可迭代的对象,当接受一个函数时,将可迭代对象的值一个个作为参数传入函数进行过滤;当没有传入函数时,将可迭代对象中为True的元素返回,返回的也是一个可迭代对象。def is_add(x): return x%2==1a = filter(is_add, [0,2,3,4,5,6,7,原创 2020-08-03 17:28:11 · 154 阅读 · 2 评论