
Python数据分析
gCodeTop 格码拓普 老师
一线程序代码工作者、教师。格码拓普:http://www.gcode.top
展开
-
pip install 镜像安装事项
国内镜像源 清华:https://pypi.tuna.tsinghua.edu.cn/simple 阿里云:http://mirrors.aliyun.com/pypi/simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 华中理工大学:http://pypi.hustunique.com/ 山东理工大学:http://pypi.sdutlinux.org/ 豆瓣:http://pypi.douban.com/simple/ 临时使用转载 2022-05-10 22:13:24 · 526 阅读 · 0 评论 -
Python对文件的数据处理-基本练习1
有一个记事本:num.txt,有5个数字,内容如下: 1 100 200 10 1 -------- Python程序读取这5个数字,然后求和,把和再写入到这个文件的尾部,即横杠下方. 参考代码1: f=open("src\\num.txt","r") strList=f.readlines() f.close() strList.pop() floatList=list(map(lambda e:int(e),strList)) s=sum(floatList) f=open("src\\nu原创 2021-11-09 17:49:40 · 596 阅读 · 0 评论 -
Python 的openpyxl模块的图表测试-1
参考代码1: from openpyxl import Workbook from openpyxl.chart import ( AreaChart, Reference, Series, ) wb = Workbook() ws = wb.active rows = [ ['Number', 'Batch 1', 'Batch 2'], [2, 40, 30], [3, 40, 25], [4, 50, 30], [5, 30, 1原创 2021-04-25 11:05:06 · 237 阅读 · 0 评论 -
Python模块openpyxl的基本测试-1
参考代码: import openpyxl from openpyxl import Workbook fn=r'student.xlsx' wb=openpyxl.load_workbook(fn) ws=wb.worksheets[0] ListScore=[] FemaleListScore=[] MaleListScore=[] for row in ws.rows: if(row[3].value=="Score"): continue if(row[2].value=="F"):原创 2021-04-20 11:10:11 · 156 阅读 · 0 评论 -
Python模块openpyxl的基本测试-2
测试代码1: import openpyxl from openpyxl import Workbook import random def generateRandomInformation(filename): wb=Workbook() ws=wb.worksheets[0] ws.append(['Name','Subject','Grade']) first='赵钱孙李' middle='伟昀琛东' last='坤艳志' subjects=('语文','数原创 2021-04-20 11:06:32 · 451 阅读 · 1 评论 -
使用Python完成Excel的数据处理-1
1.第三方相关库: http://yumos.gitee.io/openpyxl3.0/index.html https://zhuanlan.zhihu.com/p/150045444?from_voters_page=true https://blog.csdn.net/weixin_43094965/article/details/82226263 https://www.jianshu.com/p/537ae962f3a0原创 2021-04-18 22:02:57 · 158 阅读 · 0 评论 -
爬网BeautifulSoup测试
代码演示: import requests from bs4 import BeautifulSoup import re def SpiderGet(url): try: r=requests.get(url,timeout=30) # r.rasie_for_status() r.encoding='utf-8' return r.text except: print("出现异常.") return "" url="http://www.exesoft.cn" so原创 2021-04-08 20:22:20 · 140 阅读 · 0 评论 -
Python数据分析基本功训练:Python代码推导式汇编
111111111111 #1 a = 1 b = 2 c = a if a>b else b print(c) #2 a = [1,2,3,4,5,6] c = [i for i in a if i%2==0] print(sum(c)) #3 c={i for i in a if i%2==0} print(c) #4 c={i:i**i for i in a if i%2==0} print(c) #5 a = [1,2,3] b = [4,5,6] c = [i+j for i in a原创 2020-08-29 12:41:14 · 236 阅读 · 0 评论 -
Python数据分析基本功训练:Numpy及Pandas的基本使用A
1. import pandas as pd obj=pd.Series([True,3,'24','a',12.56]) print(obj) print(obj.values) print(obj.index) print(obj[3]) 2. import pandas as pd obj=pd.Series([1,3,8,24,23],index=['a','b','c','d','e']) print(obj) print(obj.index) print(obj['d']) 3.原创 2020-08-25 17:48:14 · 485 阅读 · 0 评论