本文整理匯總了Python中pandas.core.frame.DataFrame.iterrows方法的典型用法代碼示例。如果您正苦於以下問題:Python DataFrame.iterrows方法的具體用法?Python DataFrame.iterrows怎麽用?Python DataFrame.iterrows使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pandas.core.frame.DataFrame
的用法示例。
在下文中一共展示了DataFrame.iterrows方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getList
# 需要導入模塊: from pandas.core.frame import DataFrame [as 別名]
# 或者: from pandas.core.frame.DataFrame import iterrows [as 別名]
def getList(self,week, club, colList, filename):
s = pd.read_csv(filename)
df2 = DataFrame(s)
df3 = DataFrame(s)
columns = df2.columns
xlist = list()
for c in columns:
if c.upper().find("PRICE ADJUSTMENT") == -1:
if c.find(week) != -1:
xlist.append(str(c))
indexList = list()
for xcolumn in xlist:
colist = list()
colist.append(xcolumn)
df4 = DataFrame(df3, columns=colist)[~df3[xcolumn].isnull()]
for row in df4.iterrows():
if row[1][0] == club:
indexList.append(row[0])
fin = DataFrame(df2, index=indexList, columns=colList)
if fin.empty:
return
fin["Camp"] = club
fin["Week"] = week
return fin
示例2: getCamps
# 需要導入模塊: from pandas.core.frame import DataFrame [as 別名]
# 或者: from pandas.core.frame.DataFrame import iterrows [as 別名]
def getCamps(self,week):
s = pd.read_csv("D:/UTDallasStudy/summer.csv")
df2 = DataFrame(s)
df3 = DataFrame(s)
columns = df2.columns
x = set()
xlist = list()
ylist = list()
for c in columns:
if c.upper().find("PRICE ADJUSTMENT") == -1:
if c.find(week) != -1:
x.add(re.split("\.?", str(c))[0])
ylist.append(c)
else:
x.add(str(c))
for x1 in x: xlist.append(x1)
xlist.sort(cmp=None, key=None, reverse=False)
campset = set()
for y in ylist:
clist = list()
clist.append(y)
res = DataFrame(df3, columns=clist)[~df3[y].isnull()]
for row in res.iterrows():
campName = row[1][0]
campset.add(campName)
camplist = list()
for camp in campset: camplist.append(camp)
camplist.sort(cmp=None, key=None, reverse=False)
return camplist