<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Summary
Do I sleep less on nights when the Warriors play?
Step1:  The NBA season starts at the end of October. I got my fitbit near the beginning of November, so there is a lot of overlap.
A simple test
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
import os
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
import nba_py
sns.set_context('poster')
import plotly.offline as py
import plotly.graph_objs as go
py.init_notebook_mode(connected=True)
data_path = os.path.join(os.getcwd(), os.pardir, 'data', 'interim', 'sleep_data.csv')
df_sleep = pd.read_csv(data_path, index_col='shifted_datetime', parse_dates=True)
df_sleep.index += pd.Timedelta(hours=12)
sleep_day = df_sleep.resample('1D').sum().fillna(0)
from nba_py import league
gswlog = league.GameLog(player_or_team='T')
league_logs = gswlog.json['resultSets'][0]['rowSet']
columns = gswlog.json['resultSets'][0]['headers']
df_league = pd.DataFrame(league_logs, columns=columns)
df_league.columns
gsw_games = df_league[df_league['TEAM_ABBREVIATION'] == 'GSW']
len(gsw_games)
gsw_games.head()
gsw_dates = gsw_games['GAME_DATE']
toplot = sleep_day['minutesAsleep']/60.
data = []
data.append(
    go.Scatter(
        x=toplot.index,
        y=toplot.values,
        name='Hours Asleep'
    )
)
shapes = []
for idate, gsw_date in enumerate(gsw_dates):
    if idate == 0:
        showlegend = True
    else:
        showlegend = False
    trace0 = go.Scatter(
        x=[gsw_date],
        y=[toplot.dropna().min()],
        mode='markers',
        name='Golden State Warriors Game',
        marker=dict(
            color='salmon'
        ),
        showlegend=showlegend
    )
    data.append(trace0)
layout = go.Layout(
    title="Daily Sleep Total, 6pm to 6pm",
    yaxis=dict(
        title='Hours Asleep'
    ),
)
fig = {
    'data': data,
    'layout': layout,
}
py.iplot(fig, filename='DailySleepTotal_GSWGames')
Explanation: Summary
Do I sleep less on nights when the Warriors play?
End of explanation
gsw_dates = pd.to_datetime(gsw_dates)
gswdatedf = pd.DataFrame(index=gsw_dates)
gswdatedf['game_status'] = 1
gswdatedf = gswdatedf.resample('1D').sum().fillna(0)
gswdatedf_next = gswdatedf.copy()
gswdatedf_next.index += pd.Timedelta(hours=24)
sleepgsw = sleep_day.join(gswdatedf_next, how='inner')
sleepgswyes = sleepgsw.groupby('game_status').mean()
sleepgswyes['minutesAsleep'] / 60
Explanation: The NBA season starts at the end of October. I got my fitbit near the beginning of November, so there is a lot of overlap.
A simple test: sleep on the night of a Warriors game vs. all other nights. 
Here, we have to be careful about the definition of a night of sleep. I follow Fitbit's convention and assert that hours of sleep on a given date correspond to falling asleep the night before and waking up the day of. So if I fall asleep on Tuesday August 8th at 11pm and wake up on Wednesday August 9th at 7am, then I got 8 hours of sleep on August 9th.
To answer my question about sleep on the night of a Warriors game, I need to compare sleep the day AFTER the Warriors game to all other nights. E.g., the Warriors had a game on April 8, 2017. The relevant night of sleep for that game is April 9, 2017. A quick and dirty way to tackle this is by adding 24 hours to the Warriors game dates.
End of explanation
<END_TASK>