- 博客(51)
- 收藏
- 关注
原创 python合并多个excel表格到一张表中
import pandas as pdimport ospwb = "D:/PY/合并文件"df_list = []for path, dirs, files, in os.walk(pwb): for file in files: file_path = os.path.join(path, file) df = pd.read_excel(f...
2019-12-17 14:54:12
1232
原创 python操作excel合并单元格
import xlwtimport xlwings as xwdef set_style(name, height, bold=False): style = xlwt.XFStyle() font = xlwt.Font() font.bold = bold font.colour_index = 4 font.height = height ...
2019-12-17 13:33:44
1537
原创 栈
文章目录栈栈Stack() 创建一个新的空栈push(item) 添加一个新的元素item到栈顶pop() 弹出栈顶元素peek() 返回栈顶元素is_empty() 判断栈是否为空size() 返回栈的元素个数# -*-coding:utf-8_*-class Stack(object): """栈""" def __init__(self): ...
2019-12-12 18:50:24
106
原创 子图
import matplotlib.pyplot as pltimport numpy as npx = np.arange(1,100)fig = plt.figure()ax1 = fig.add_subplot(221)ax1.plot(x,x)ax2 = fig.add_subplot(222)ax2.plot(x,-x)ax3 = fig.add_subplot(223)...
2019-12-09 19:41:03
124
原创 自己举例-三条平滑折线图
import numpy as npimport matplotlib.pyplot as pltfrom scipy.interpolate import spliney1 =np.array([10,15,22,16,36])y2 =np.array([9,14,20,20,40])y3 =np.array([11,19,18,15,23])x = np.array([1,2,3,...
2019-12-09 17:34:48
213
原创 颜色和样式
import numpy as npimport matplotlib.pyplot as plty = np.arange(1, 5)plt.plot(y, color="g")plt.plot(y+1, color="0.5")plt.plot(y+2, color="#FF00FF")plt.plot(y+3, color=(0.1, 0.2, 0.3))plt.show()...
2019-12-09 15:34:51
174
原创 箱型图
import numpy as npimport matplotlib.pyplot as pltnp.random.seed(100)data = np.random.normal(size=1000,loc=0,scale=1)plt.boxplot(data, sym="o", whis=1.5) # whis 代表虚线的长度,用来调节异常值的包括范围。plt.show()n...
2019-12-09 15:10:34
114
原创 饼状图
import matplotlib.pyplot as pltlabels = "A","B","C","D"fracs = [15,30,45,10]explode = [0,0.1,0,0]plt.axes(aspect=1) # 比例为1:1,即转化为正圆。plt.pie(x=fracs, labels=labels, autopct="%.0f%%", explode=explo...
2019-12-09 14:56:15
132
原创 直方图
mu = 100 # mean of distributionsigma = 20 # standard devition of distributionx = mu + sigma*np.random.randn(2000)plt.hist(x,bins=50,color="red",normed=False)plt.show()结果:x = np.random.randn(10...
2019-12-09 14:31:30
92
原创 条形图
import numpy as npimport matplotlib.pyplot as pltN=5y=[20,10,30,25,15]index = np.arange(N)pl = plt.bar(left=index, height=y)plt.show()结果是:N=5y=[20,10,30,25,15]index = np.arange(N)pl = p...
2019-12-09 14:15:30
89
原创 散点图和折线图等
import matplotlib.pyplot as pltimport numpy as np# x = np.loadtxt("test1201.csv", delimiter=",", skiprows=1,usecols=(1,3,5),unpack=False)# print(x)# open,close,volume = np.loadtxt("test1201.csv",...
2019-12-06 09:38:00
299
原创 可视化
%matplotlib inlineimport pandas as pdimport numpy as npts = pd.Series(np.random.randn(1000),index=pd.date_range("2000/1/1",periods=1000))ts = ts.cumsum()ts.describe()count 1000.000000mean ...
2019-12-02 09:50:13
235
原创 时间日期
import pandas as pdimport numpy as npfrom datetime import datetimefrom datetime import timedeltanow = datetime.now()nowdatetime.datetime(2019, 11, 30, 17, 47, 19, 223904)now.year, now.month, n...
2019-12-01 21:30:55
85
原创 时间日期
import pandas as pdimport numpy as npfrom datetime import datetimefrom datetime import timedeltanow = datetime.now()nowdatetime.datetime(2019, 11, 30, 17, 47, 19, 223904)now.year, now.month, n...
2019-11-30 19:40:46
83
原创 pandas_read_csv
import pandas as pdimport numpy as nppd.read_csv("D:/PY/book1.csv") 返回目录 Unnamed: 1 制造费用分配预算表(按照工时分配) Unnamed: 3 Unnamed: 4 Unnamed: 5 Un...
2019-11-26 13:16:42
164
原创 聚合运算1
import pandas as pdimport numpy as npdf = pd.DataFrame({"key1":["a","a","b","b","a"], "key2":["one","two","one","two","one"], "data1":np.random.randint(1,10,5), ...
2019-11-25 21:19:03
188
原创 groupby
import pandas as pdimport numpy as npdf = pd.DataFrame({"key1":["a","a","b","b","a"], "key2":["one","two","one","two","one"], "data1":np.random.randint(1,10,5), ...
2019-11-24 17:51:37
127
原创 pandas-1118-02
import pandas as pdimport numpy as nps = pd.Series(np.random.randn(5), index=list("abcde"))sa 0.635448b -0.010749c 0.283827d -1.205425e 0.278554dtype: float64s.indexIndex(['a'...
2019-11-18 17:28:22
96
原创 pandas_基础课1118
import pandas as pdimport numpy as nps = pd.Series(np.random.randn(5), index=["a","b","c","d","e"])sa 0.365672b -0.259483c -0.404180d -0.310866e -0.256827dtype: float64s.indexI...
2019-11-18 10:08:25
208
原创 pandas_基础课
import pandas as pdimport numpy as nps = pd.Series(np.random.randn(5), index=["a","b","c","d","e"])sa 0.365672b -0.259483c -0.404180d -0.310866e -0.256827dtype: float64s.indexI...
2019-11-17 19:33:54
116
原创 movies1117
import pandas as pdunames = ["user_id","gender","age","occupation","zip"]users = pd.read_table("D:/蒋雪梅/python/pandas课件/ml-1m/ml-1m/users.dat",sep="::", header=None,names=unames)C:\Users\jxm\Anacond...
2019-11-17 16:28:54
448
原创 pandas_1117
%matplotlib inlineimport pandas as pdimport numpy as npimport matplotlib.pyplot as plttuples = list(zip(*[["bar","bar","baz","baz", "foo","foo","qux","qux"], ...
2019-11-17 11:28:22
154
原创 pandas__11
%matplotlib inlineimport pandas as pdimport numpy as npimport matplotlib.pyplot as pltdates = pd.date_range("20160301",periods=6)df = pd.DataFrame(np.random.randn(6,4), index=dates, columns=list(...
2019-11-17 10:23:19
61
原创 pandas入门学习第一天第一部分
In [1]: import pandas as pdIn [2]: import numpy as npIn [3]: s = pd.Series([1,3,5,np.Na])In [4]: dates = pd.date_range("20160301", periods=6)In [5]: datesDatetimeIndex(['2016-03-01', '2016-03-02'...
2019-11-16 21:41:59
93
原创 numpy学习第一天最后一部分
文章目录numpynumpyimport numpy as npa = np.zeros((3, 4))print(a)a = np.empty((3, 4))print(a)a = np.arange(10, 20, 2)print(a)a = np.linspace(1, 10, 20)print(a)a = np.linspace(1, 10, 6).resha...
2019-11-16 19:31:40
94
原创 机器学习第一天第一部分
文章目录numpy&pandas安装numpy属性numpy&pandas安装pip install numpypip install pandasnumpy属性import numpy as nparray = np.array([[1, 2, 3], [2, 3, 4]])print(array)print("number ...
2019-11-15 22:08:36
85
原创 数据结构学习第三天
文章目录单链表单链表class Node(object): """节点""" def __init__(self, elem): self.elem = elem self.next = Noneclass SingleLinkList(object): """单链表""" def __init__(self, node...
2019-11-15 21:46:40
68
原创 python数据结构与算法-第一节课
文章目录时间复杂度timeit模块抽象数据类型时间复杂度1、基本操作,即只有常数项,时间复杂度为O(1)2、顺序结构:按加法计算。3、循环结构:按照乘法计算。4、分支结构:取最大值。5、在没有特殊说明的情况下,时间复杂度都是指的最坏时间复杂度。timeit模块class timeit.Timer(stmt=“pass”,setup=“pass”,timer=)timeit.Tim...
2019-11-11 09:05:44
91
原创 python学习第十四天
文章目录SQL1、链接对象:2、游标3、参数化查询:避免SQL注入:SQL1、链接对象:commit()close()2、游标cursor=conn.cursor()execute(“SQL语句”,参数).fetchall() 选择所有.fetchone() 选择一条.fetchmany(n) 选择n条3、参数化查询:避免SQL注入:?:参数传递tuple:参数名,参数...
2019-11-09 14:20:58
77
原创 python第十三节课
文章目录CSV文件读取json结果是:原始数据{"ID": 1, "\u8bfe\u7a0b": "python", "\u673a\u6784": "\u4f18\u54c1"}excel文件读取结果是:工作簿:损益表1数据行数:8集团损益表CSV文件读取jsondef json_basic(): data = { "ID": 1, "课程"...
2019-11-09 11:21:32
205
原创 python学习第十二天
文章目录单线程案例放鸡蛋案例加锁放鸡蛋案例先进先出法装饰器返回大写的装饰器定义类装饰器参数装饰器单线程案例import timedef worker(n): print("函数执行开始于:{}".format(time.ctime())) time.sleep(n) print(f"函数执行结束于:{time.ctime()}")def main(): ...
2019-11-08 12:51:41
106
原创 python第十天学习
文章目录文件写入pickleshelve字符编码类型转换文件写入scores = [88 , 99 , 90 , 56]def write_scores(): with open("data_list.txt","w",encoding="utf8") as f: f.write(str(scores)) print("文件写入完成")if __na...
2019-11-02 19:42:46
103
原创 异常处理及测试
try:有可能出现的异常except异常类型as实例,捕获特定异常。finally:无论是否遇到异常均会执行。raise:手动抛出异常。测试的实例def get_formatted_name(first,last): full_name = "{}{}".format(first,last) return full_name.title()print(get_forma...
2019-11-01 18:22:22
250
原创 面向对象编辑OOP3
多态:同一类型的不同实例对同一消息做出的不同反应。第一种方法import mathclass Circle: def __init__(self,radius): self.radius = radius def get_area(self): return math.pi * self.radius ** 2c = Circle(6...
2019-10-31 18:37:41
124
原创 面向对象
文章目录封装封装封装、继承、多态class Book: def __init__(self,title,price=0.0,author=None): self.title = title self.price = price self.author = author def print_info(self): ...
2019-10-31 14:26:44
57
原创 包与模块管理
文章目录模块fromimport包面向对象编程封装类模块fromfrom 引入整个模块from…import…as…importimprot 可以引入其他模块的信息包importlib不能用from的方式重新载入,只能是模块的方式面向对象编程封装字典表类classimport datetimeclass Book: def __init__(self,titl...
2019-10-31 08:19:47
93
原创 函数应用与工具
文章目录函数应用与工具action案例1案例2函数应用与工具f = lambda name,age : print("hello{},age:{}".format(name,age))f("tom",20)结果是:hellotom,age:20actiondef hello_ch(name): print("您好:", name)def hello_english...
2019-10-29 15:52:44
74
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人