From b332f75cc9f5d69904e04651ebfee35649cf01fb Mon Sep 17 00:00:00 2001 From: Dylan Date: Sat, 13 Jan 2024 21:53:55 -0500 Subject: [PATCH 1/2] Update __init__.py Update import_weekly_rosters to check if "age" column was specified by user before computing it for return. NOTE: this will additionally provide a workaround for https://github.com/cooperdff/nfl_data_py/issues/75 for users that do not require "age" in the output, given that column's computation is causing the errors described in that issue. --- nfl_data_py/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nfl_data_py/__init__.py b/nfl_data_py/__init__.py index 604ba7c..84c829e 100644 --- a/nfl_data_py/__init__.py +++ b/nfl_data_py/__init__.py @@ -471,7 +471,8 @@ def import_weekly_rosters(years, columns=None): how="left" ).gameday ) - rosters["age"] = ((roster_dates - rosters.birth_date).dt.days / 365.25).round(3) + if "age" in columns: + rosters["age"] = ((roster_dates - rosters.birth_date).dt.days / 365.25).round(3) return rosters From 83d8e3bcca57de9d2b40452d0f7000194bb07a58 Mon Sep 17 00:00:00 2001 From: Dylan Date: Sat, 13 Jan 2024 21:59:04 -0500 Subject: [PATCH 2/2] Update __init__.py Added None check for columns variable in weekly_import_rosters (before checking for presence of value in the list). --- nfl_data_py/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nfl_data_py/__init__.py b/nfl_data_py/__init__.py index 84c829e..94d8930 100644 --- a/nfl_data_py/__init__.py +++ b/nfl_data_py/__init__.py @@ -471,7 +471,7 @@ def import_weekly_rosters(years, columns=None): how="left" ).gameday ) - if "age" in columns: + if columns is not None and "age" in columns: rosters["age"] = ((roster_dates - rosters.birth_date).dt.days / 365.25).round(3) return rosters