随笔分类 -  python

摘要:python pandas 库API说明文档链接 pandas.DataFrame.apply — pandas 1.4.3 documentation (pydata.org) 阅读全文
posted @ 2022-08-23 13:55 司徒韵然 阅读(69) 评论(0) 推荐(0) 编辑
摘要:python pandas DataFrame如何把两个DataFrame合并,pd.merge_ordered() 1 import pandas as pd 2 import numpy as np 3 df1 = pd.DataFrame({ 4 'datetime':['2021-01-01 阅读全文
posted @ 2022-08-23 09:42 司徒韵然 阅读(349) 评论(0) 推荐(0) 编辑
摘要:1 import pandas as pd 2 import six.moves.cPickle as cPickle 3 import gzip 4 5 filePath = './a/data.pkl.gz' 6 f = gzip.open(filePath,'rb') 7 df = pd.Da 阅读全文
posted @ 2022-08-18 16:53 司徒韵然 阅读(224) 评论(0) 推荐(0) 编辑
摘要:函数的形参前面带一个星*,代表着不定长参数,实际上是收集了不定长的实参,作为一个元组。 形参前面带两个星**,代表可以接收不定长参数,并且调用该函数时实参要指定参数名,实际上是收集了一个不定键个数的字典。 实参前带一个星*,表示解开当前的序列,再做为参数传递。 实参前带两个星**,表示解开当前的字典 阅读全文
posted @ 2022-08-15 17:43 司徒韵然 阅读(436) 评论(0) 推荐(0) 编辑
摘要:python itertools.product() 用来产生多个序列的笛卡尔积,参数可两个或者多个序列,元组tulple,列表list,range生成的序列,集合set都可作为参数 1 import itertools 2 # parameter1 = range(1,3,1) 3 # param 阅读全文
posted @ 2022-08-15 15:54 司徒韵然 阅读(381) 评论(0) 推荐(0) 编辑
摘要:怎么给pandas DataFrame 格式的数据其中的列分成两列或者多列呢 用map() 和split()两个内置函数 例如: 1 import pandas as pd 2 df = pd.DataFrame({'dateTime':['2021-02-01 10:10:21','2022-03 阅读全文
posted @ 2022-08-15 13:22 司徒韵然 阅读(1819) 评论(0) 推荐(0) 编辑
摘要:python 用pandas库来从csv 文件读取数据,保存数据到 csv 文件 excel文件 DataFrame 分组 df.groupby() 1 import pandas as pd 2 import os 3 4 path = './' 5 read_csv_filename = 'da 阅读全文
posted @ 2022-08-14 15:25 司徒韵然 阅读(441) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2022-08-14 14:51 司徒韵然 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2022-08-14 14:38 司徒韵然 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2022-08-14 14:37 司徒韵然 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2022-08-14 14:34 司徒韵然 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2022-08-14 14:31 司徒韵然 阅读(92) 评论(0) 推荐(0) 编辑
摘要:删除python DataFrame 最后一行, all_data.drop(all_data.tail(1).index,inplace=True) 或者 all_data.drop([len(all_data)-1],inplace=True)删除最后n行 all_data.drop(all_d 阅读全文
posted @ 2022-07-22 17:02 司徒韵然 阅读(6493) 评论(0) 推荐(0) 编辑
摘要:使用.json作为后缀名的配置文件,在python中读取,如下 datafile.json文件: { "name" : "szeto", "password" : "abc123", "hobby" : ["drawing","running","study"] } python代码: 1 impo 阅读全文
posted @ 2022-07-17 19:25 司徒韵然 阅读(660) 评论(0) 推荐(0) 编辑
摘要:excel是常用的处理数据的工具,那么怎样把python中的pandas库中DataFrame格式的数据保存到excel表格呢?代码如下。 1 import pandas as pd 2 df1=pd.DataFrame({'Data1':[1,2,3,4,5]}) 3 df2=pd.DataFra 阅读全文
posted @ 2022-07-17 18:59 司徒韵然 阅读(3103) 评论(0) 推荐(0) 编辑
摘要:python calendar库monthrange函数可以返回指定月份的最后一天 1 import calendar 2 lastDay = calendar.monthrange(2022,2)[1] 3 #返回28 4 lastDay2 = calendar.monthrange(2024,2 阅读全文
posted @ 2022-07-17 18:44 司徒韵然 阅读(723) 评论(0) 推荐(0) 编辑

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