#詹姆斯上场时,湖人的胜率'''
这块的计算错了,也放在上面给大家看一下
主要原因是dataframe与字符串的比较
#df_james.date.values[i]
def LA_WP(dates):
''''''
。。。
'''
win_times=0
lose_times=0for date in dates:#win_times = 0#lose_times = 0
winner = df_team_sim[df_team_sim["date"]==date].winner.values
if winner.all()=="Los Angeles Lakers":
win_times +=1else:
lose_times+=1return("胜利场次:%d,失败场次:%d,胜率:%.2f"%(win_times,lose_times,win_times/(win_times+lose_times)))
LA_WP(df_james.date.values)
'胜利场次:23,失败场次:29,胜率:0.44'
计算詹姆斯不在场时,湖人的胜率
先不管上面的错误,计算詹姆斯不在场时,湖人的胜率
#詹姆斯不在场时,湖人的胜率#找出詹姆斯不在场的比赛的时间,用isin取反即可
df_nojames = df_team_sim[~df_team_sim["date"].isin(df_james["date"])]
df_nojames = df_nojames[(df_nojames["home_team"]=="Los Angeles Lakers")|( df_nojames["away_team"]=="Los Angeles Lakers")]len(df_nojames)
27
win_games = df_nojames[df_nojames["winner"]=="Los Angeles Lakers"]
lose_games = df_nojames[df_nojames["loser"]=="Los Angeles Lakers"]
wp_nojames =len(win_games)/(len(win_games)+len(lose_games))
wp_nojames
0.4444444444444444
lose_games
date
home_team
home_score
away_team
away_score
winner
loser
523
2021-03-03T22:00:00
Sacramento Kings
123
Los Angeles Lakers
120
Sacramento Kings
Los Angeles Lakers
625
2021-03-21T22:00:00
Phoenix Suns
111
Los Angeles Lakers
94
Phoenix Suns
Los Angeles Lakers
635
2021-03-23T19:30:00
New Orleans Pelicans
128
Los Angeles Lakers
111
New Orleans Pelicans
Los Angeles Lakers
655
2021-03-25T22:00:00
Los Angeles Lakers
101
Philadelphia 76ers
109
Philadelphia 76ers
Los Angeles Lakers
704
2021-03-31T22:00:00
Los Angeles Lakers
97
Milwaukee Bucks
112
Milwaukee Bucks
Los Angeles Lakers
731
2021-04-04T15:30:00
Los Angeles Clippers
104
Los Angeles Lakers
86
Los Angeles Clippers
Los Angeles Lakers
761
2021-04-08T19:30:00
Miami Heat
110
Los Angeles Lakers
104
Miami Heat
Los Angeles Lakers
795
2021-04-12T19:30:00
New York Knicks
111
Los Angeles Lakers
96
New York Knicks
Los Angeles Lakers
824
2021-04-15T22:00:00
Los Angeles Lakers
113
Boston Celtics
121
Boston Celtics
Los Angeles Lakers
858
2021-04-19T22:00:00
Los Angeles Lakers
97
Utah Jazz
111
Utah Jazz
Los Angeles Lakers
881
2021-04-22T21:30:00
Dallas Mavericks
115
Los Angeles Lakers
110
Dallas Mavericks
Los Angeles Lakers
894
2021-04-24T20:30:00
Dallas Mavericks
108
Los Angeles Lakers
93
Dallas Mavericks
Los Angeles Lakers
923
2021-04-28T19:30:00
Washington Wizards
116
Los Angeles Lakers
107
Washington Wizards
Los Angeles Lakers
993
2021-05-06T22:00:00
Los Angeles Clippers
118
Los Angeles Lakers
94
Los Angeles Clippers
Los Angeles Lakers
1002
2021-05-07T22:00:00
Portland Trail Blazers
106
Los Angeles Lakers
101
Portland Trail Blazers
Los Angeles Lakers
#根据时间和队名的匹配,找出詹姆斯在场的每一个比赛,组合到一个dataframe中
data = pd.DataFrame()for i inrange(len(df_james)):
james_game = df_team_sim[(df_team_sim["date"]==df_james["date"].values[i])&((df_team_sim["winner"]=="Los Angeles Lakers")|(df_team_sim["loser"]=="Los Angeles Lakers"))]
data = pd.concat([data,james_game])
#詹姆斯在场上的时候胜率wp_james
james_win =len(data[data["winner"]=="Los Angeles Lakers"])
james_lose =len(data[data["loser"]=="Los Angeles Lakers"])
wp_james = james_win/(james_win+james_lose)
wp_james
/*
*开发触发器
*/
--得到日期是周几
select to_char(sysdate+4,'DY','nls_date_language=AMERICAN') from dual;
select to_char(sysdate,'DY','nls_date_language=AMERICAN') from dual;
--建立BEFORE语句触发器
CREATE O
下面给大家整理了一些vim NERDTree的常用快捷键了,这里几乎包括了所有的快捷键了,希望文章对各位会带来帮助。
切换工作台和目录
ctrl + w + h 光标 focus 左侧树形目录ctrl + w + l 光标 focus 右侧文件显示窗口ctrl + w + w 光标自动在左右侧窗口切换ctrl + w + r 移动当前窗口的布局位置
o 在已有窗口中打开文件、目录或书签,并跳