gpt-3.5-turbo-0613· openai
Suzhen/CodeChat
can I create a gameid column in the gamedata that simply sets game id to the row number…
- User
can I create a game_id column in the game_data that simply sets game id to the row number at 5 digits as a float? IE 00011 00002
Column extraction
columns_to_extract = [ 'id', 'scheduled', 'summary.home.id', 'summary.home.name', 'summary.away.id', 'summary.away.name', 'summary.home.points', 'summary.away.points' ] odds_columns = [col for col in historical_df.columns if col.startswith('summary.odds.')] columns_to_extract.extend(odds_columns) game_data = historical_df[columns_to_extract] - Assistant
Yes, you can create a
game_idcolumn in thegame_dataDataFrame that sets the game id to the row number as a 5-digit float.Here's an example of how you can do this:
game_data['game_id'] = game_data.index.map(lambda x: f"{x:05d}")This code uses the
index.map()function to map each row index to a 5-digit string using formatted string syntax with a width specifier of 5. The leading zeros will be added to ensure that the resulting strings are always 5 digits long.You can then access the
game_idcolumn ingame_datato get the game ids for each row.