摘要: 1 import pymysql 2 import pandas 3 db=pymysql.connect(host='localhost',port=3306,user='root',database='lihao',password='lh19990317') 4 #cursor=db.curs 阅读全文
posted @ 2020-06-15 11:20 马蹄哒哒 阅读(183) 评论(0) 推荐(0)
摘要: import pandas import numpy page1=pandas.read_excel('成绩.xlsx',sheet_name='Sheet1') page2=pandas.read_excel('成绩.xlsx',sheet_name='Sheet2') page1.columns 阅读全文
posted @ 2020-06-15 09:45 马蹄哒哒 阅读(416) 评论(0) 推荐(0)
摘要: Counter类: Counter类的目的是用来跟踪值出现的次数。它是一个无序的容器类型,以字典的键值对形式存储,其中元素作为key,其计数作为value。计数值可以是任意的Interger(包括0和负数)。Counter类和其他语言的bags或multisets很相似。 (一)创建Counter类 阅读全文
posted @ 2020-06-14 22:39 马蹄哒哒 阅读(4572) 评论(0) 推荐(0)
摘要: import pandas sheet1=pandas.read_excel('成绩.xlsx',sheet_name='Sheet1') sheet2=pandas.read_excel('成绩.xlsx',sheet_name='Sheet2') 连接两张表 students=sheet1.ap 阅读全文
posted @ 2020-06-14 17:57 马蹄哒哒 阅读(324) 评论(0) 推荐(0)
摘要: 1 import pandas 2 from matplotlib import pyplot 3 from scipy.stats import linregress 4 sale=pandas.read_excel('销售.xlsx',dtype={'date':str}) 5 6 7 slop 阅读全文
posted @ 2020-06-14 11:24 马蹄哒哒 阅读(378) 评论(0) 推荐(0)
摘要: 1 import pandas 2 import numpy 3 csv=pandas.read_csv('salesmen.csv') 4 csv['Month']=pandas.DatetimeIndex(csv['Date']).month 5 6 #透视表制作方法一: 7 #pt=csv.p 阅读全文
posted @ 2020-06-13 13:14 马蹄哒哒 阅读(301) 评论(3) 推荐(0)
摘要: 1 import pandas 2 csv=pandas.read_csv('salesmen.csv') 3 tsv=pandas.read_csv('a.tsv',sep='\t') #sep代表制表符的种类 4 txt=pandas.read_csv('b.txt',sep='-') 5 pr 阅读全文
posted @ 2020-06-13 12:28 马蹄哒哒 阅读(353) 评论(0) 推荐(0)
摘要: 1 import pandas 2 pandas.options.display.max_columns=20 #显示所有的列名 3 excel=pandas.read_excel('成绩.xlsx',index_col='id') 4 table=excel.transpose() #旋转表 5 阅读全文
posted @ 2020-06-13 11:38 马蹄哒哒 阅读(204) 评论(0) 推荐(0)
摘要: 1 import pandas 2 excel=pandas.read_excel('成绩.xlsx',sheet_name='Sheet1') 3 #excel.drop_duplicates(subset='name',inplace=True,keep='last') #keep默认为Firs 阅读全文
posted @ 2020-06-13 11:32 马蹄哒哒 阅读(200) 评论(0) 推荐(0)
摘要: 1 import pandas 2 excel=pandas.read_excel(r'F:\pandas练习\成绩.xlsx',index_col='id',sheet_name='Sheet1') 3 temp=excel[['score1','score2']] 4 5 row_sum=tem 阅读全文
posted @ 2020-06-12 13:43 马蹄哒哒 阅读(228) 评论(0) 推荐(0)