From 20cda888d2aad62b1b0cc4831e0a64c0ba384b83 Mon Sep 17 00:00:00 2001 From: MMuta52 Date: Sat, 11 Jun 2022 14:07:57 -0500 Subject: [PATCH] Updating pandas concat syntax --- nfl_data_py/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nfl_data_py/__init__.py b/nfl_data_py/__init__.py index 0826fa9..2b3947a 100644 --- a/nfl_data_py/__init__.py +++ b/nfl_data_py/__init__.py @@ -74,6 +74,7 @@ def import_pbp_data(years, columns=None, downcast=True, cache=False, alt_path=No appauthor = 'cooper_dff' plays = pandas.DataFrame() + pbp_data = [] if cache is True: @@ -109,16 +110,16 @@ def import_pbp_data(years, columns=None, downcast=True, cache=False, alt_path=No raw = pandas.DataFrame(data) raw['season'] = year - if len(plays) == 0: - plays = raw - else: - plays = plays.append(raw) + pbp_data.append(raw) print(str(year) + ' done.') except: print('Data not available for ' + str(year)) + if len(pbp_data) > 0: + plays = pandas.concat(pbp_data).reset_index(drop=True) + # converts float64 to float32, saves ~30% memory if downcast: print('Downcasting floats.')