pd.Series([1,2,3,4,5])
d=pd.DataFrame({"第一列":[11,22,33,44,55],"第二列":['a','b','c','d','e'],"第三列":"haha"}) d=pd.DataFrame([{"第一列":11,"第二列":'a'},{"第一列":22,"第二列":'b'}])
import pandas as pd
data_origin = pd.read_excel(f)#從excel中讀取數據,也能夠經過read_csv()等從其餘格式文件中讀取數據
len(data_origin)
print(data_format.index)#打印索引結果,列出索引範圍RangeIndex(start=0, stop=194, step=1)
data_format = data_origin[["標題", "解決方案"]]#得到excel第一行的內容爲列名的數據,「標題」和「解決方案」爲列名
print(data_origin.標題)#打印dataFrame中某個列的數據,這裏打印的第一列爲標題的列的數據,也能夠用data_origin.A等表達 print(data_format["標題"])
print(d.columns)#顯示全部的列表索引,對應到excel的標題 print(d.values)#顯示除標題行外的值
print(d.T)
print(d[1:3])
print(d.iloc[1].values)
print(d[(d.第一列 > 22) & (d.第二列 == 'c')])
print(data_format.query('(解決方案 not in ["不是BUG","重複BUG","沒法重現"] & 建立人 != ("林立星"))'))#這種方案也可行,可是不能直接寫變量,比較麻煩
print(data_format[(data_format.解決方案.isin(invalid_resove))])#判斷數據是否在XX區間內
bug_effective = data_format[ (data_format.狀態.isin(["已關閉"]) & ~data_format.解決方案.isin(invalid_resove))]
print(data_format.head(10))#得到dataFrame數據的前10行
data_effective.to_excel("./解析BUG結果.xls",sheet_name="有效BUG")#這種每次都會覆蓋前面保存的sheet的值
with pd.ExcelWriter('./解析BUG結果.xls') as writer: data_effective.to_excel(writer, '有效BUG') data_unkown_reslover.to_excel(writer, '未知解決人的BUG')
from openpyxl import load_workbook book= load_workbook('./存在的文件名.xlsx') writer = pd.ExcelWriter('./存在的文件名.xlsx', engine='openpyxl') writer.book = book bug_effective.to_excel(writer, ’sheet的標題') writer.save()
info[info.從新打開次數.notnull()])
.to_excel(writer,sheet名,columns=["列名1」,"列名2",」列名3」])
data[(data.修復人.notnull()) & (data.修復人.isin(RD["Android"]) | data.修復人.isin(RD["server"]))]
print(data.columns.values.tolist())