蓝绝

博客园 首页 新随笔 联系 订阅 管理
  232 随笔 :: 1 文章 :: 0 评论 :: 25926 阅读

随笔分类 -  数据分析全家桶

1 2 3 下一页

摘要:#设置轴标题 #画布设置颜色和大小 #折线图设置标记样式,,mfc='w'表示空心 import matplotlib.pyplot as plt x=[1,2,3,4,5] y=[2,10,6,7,17] plt.rcParams['font.sans-serif']=['SimHei'] plt 阅读全文
posted @ 2022-11-27 22:18 蓝绝 阅读(348) 评论(0) 推荐(0) 编辑

摘要:#画布设置颜色和大小 #折线图设置标记样式,,mfc='w'表示空心 import matplotlib.pyplot as plt x=[1,2,3,4,5] y=[2,10,6,7,17] plt.figure(facecolor='yellow',figsize=(5,3)) plt.plot 阅读全文
posted @ 2022-11-27 16:03 蓝绝 阅读(101) 评论(0) 推荐(0) 编辑

摘要:#散点图,设置标记样式 import matplotlib.pyplot as plt x=[1,2,3,4,5] y=[2,10,6,7,17] plt.plot(x,y,"r1") #r表示颜色,1表示标记样式(下花三角标记) plt.show() #折线图设置标记样式,,mfc='w'表示空心 阅读全文
posted @ 2022-11-27 15:55 蓝绝 阅读(91) 评论(0) 推荐(0) 编辑

摘要:#设置表颜色和线条灰度值 import matplotlib. pyplot as plt x=[1, 2, 3, 4, 5] y=[10, 20, 30, 40, 50] plt.plot(x,y,color='0.7',linestyle='-.') #设置灰度值为0.7,线条样式为-. plt 阅读全文
posted @ 2022-11-27 15:35 蓝绝 阅读(143) 评论(0) 推荐(0) 编辑

摘要:# 绘制简单图表 import matplotlib.pyplot as plt plt.plot([1,2,3,4,5]) plt.show() #散点图 import matplotlib.pyplot as plt plt.plot([1,2,3,4,5],[2,10,6,7,11],'ro' 阅读全文
posted @ 2022-11-27 14:23 蓝绝 阅读(27) 评论(0) 推荐(0) 编辑

摘要:import pandas as pd pd.set_option('display.unicode.east_asian_width',True) # 规整格式 df=pd.read_excel('电脑配件销售记录.xlsx') print(df.head()) df.to_html('电脑配件销 阅读全文
posted @ 2022-11-27 13:54 蓝绝 阅读(21) 评论(0) 推荐(0) 编辑

摘要:#移动窗口数据计算 import pandas as pd index=pd.date_range('2020-1-1',periods=15,freq='D') #创建Series对象 s=pd.Series(data=[3,6,7,4,2,1,3,8,9,10,12,15,13,22,14],i 阅读全文
posted @ 2022-11-27 13:26 蓝绝 阅读(48) 评论(0) 推荐(0) 编辑

摘要:#统计数据的open,close,high,low的值 import pandas as pd index=pd.date_range('2020-2-3',periods=12,freq='T') #从2020-2-3开始,12个数,间隔为1分钟 s=pd.Series(range(12),ind 阅读全文
posted @ 2022-11-27 13:03 蓝绝 阅读(31) 评论(0) 推荐(0) 编辑

摘要:import pandas as pd index=pd.date_range('2020-1-1',periods=2) s=pd.Series(range(1,3),index=index) #升采样 #s.resample('6H').asfreq() #使用前值填充 #s.resample( 阅读全文
posted @ 2022-11-27 12:47 蓝绝 阅读(19) 评论(0) 推荐(0) 编辑

摘要:import pandas as pd pd.set_option('display.unicode.east_asian_width',True) # 规整格式 df=pd.read_excel('msb课程记录.xls') df=df.set_index('订单付款时间') #df.head() 阅读全文
posted @ 2022-11-27 11:40 蓝绝 阅读(27) 评论(0) 推荐(0) 编辑

摘要:#将一分钟时间序列转换成3分钟, index=pd. date_range('2021-1-1', periods=9, freq='T') s=pd.Series (data=range (9), index=index) #产生3分钟的序列, #s. resample (rule=' 3T', 阅读全文
posted @ 2022-11-27 11:08 蓝绝 阅读(97) 评论(0) 推荐(0) 编辑

摘要:# data_range()函数的使用 import pandas as pd pd.date_range("2021-1-1",periods=10,freq="W") DatetimeIndex(['2021-01-03', '2021-01-10', '2021-01-17', '2021-0 阅读全文
posted @ 2022-11-27 10:40 蓝绝 阅读(34) 评论(0) 推荐(0) 编辑

摘要:#按时期统计并显示数据 import pandas as pd pd.set_option('display.unicode.east_asian_width',True) # 规整格式 df=pd.read_excel('msb课程销售记录.xlsx') #df.head() df=df[['订单 阅读全文
posted @ 2022-11-27 10:31 蓝绝 阅读(88) 评论(0) 推荐(0) 编辑

摘要:#按不同时期统计数据 import pandas as pd pd.set_option('display.unicode.east_asian_width',True) # 规整格式 df=pd.read_excel('日期.xlsx') df=df.set_index('订单付款日期.xlsx' 阅读全文
posted @ 2022-11-27 10:07 蓝绝 阅读(23) 评论(0) 推荐(0) 编辑

摘要:#获取指定区域的数据 import pandas as pd pd.set_option('display.unicode.east_asian_width',True) # 规整格式 df=pd.read_excel('msb课程销售记录.xlsx') #df.head() df=df[['订单付 阅读全文
posted @ 2022-11-27 09:48 蓝绝 阅读(41) 评论(0) 推荐(0) 编辑

摘要:# #dt对象的使用 import pandas as pd pd.set_option('display.unicode.east_asian_width',True) # 规整格式 df=pd.read_excel('日期.xlsx') df['日期']=pd. to_datetime (df[ 阅读全文
posted @ 2022-11-27 09:45 蓝绝 阅读(55) 评论(0) 推荐(0) 编辑

摘要:##将各种日期字符串转成日期格式 #将各种日期字符串转成日期格式 import pandas as pd pd.set_option('display.unicode.east_asian_width',True) # 规整格式 df=pd.DataFrame({'原日期':['14-Feb-20' 阅读全文
posted @ 2022-11-21 23:06 蓝绝 阅读(156) 评论(0) 推荐(0) 编辑

摘要:# #导出到csv文件 import pandas as pd df=pd.DataFrame( {'编号':['1001','1002','1003'], '姓名':['张三','李四','王五'], '总成绩':[740,658,543] }) df #导出到csv文件,不显示索引,导出列为[' 阅读全文
posted @ 2022-11-21 22:10 蓝绝 阅读(50) 评论(0) 推荐(0) 编辑

摘要:##数据导出,保存成Excel文件 #数据导出,保存成Excel文件 import pandas as pd df=pd.DataFrame( {'编号':['1001','1002','1003'], '姓名':['张三','李四','王五'] }) df df.to_excel('数据导出-学生 阅读全文
posted @ 2022-11-20 22:38 蓝绝 阅读(168) 评论(0) 推荐(0) 编辑

摘要:#纵向表合并--行相加 #concat方法,纵向数据合并(表结构相同,首尾相连) import pandas as pd df1=pd.read_excel('数据合并concat.xlsx', sheet_name='Sheetl') df2=pd.read_excel('数据合并concat.x 阅读全文
posted @ 2022-11-20 22:06 蓝绝 阅读(598) 评论(0) 推荐(0) 编辑

1 2 3 下一页
点击右上角即可分享
微信分享提示