From 1377bd65245871272eef008b70ba5326a6f37035 Mon Sep 17 00:00:00 2001 From: Omar Iqbal Naru Date: Wed, 29 Oct 2025 20:48:39 +0500 Subject: [PATCH] Fix DATE column issue - PSX website changed TIME to DATE The PSX website changed the column name from 'TIME' to 'DATE', which was causing the library to fail with 'None of ['TIME'] are in the columns' error. Changes: - Updated headers list to use 'DATE' instead of 'TIME' - Updated toframe() method to check for 'DATE' column - Updated set_index() to use 'DATE' instead of 'TIME' Tested successfully with multiple PSX stocks. --- src/psx/web.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/psx/web.py b/src/psx/web.py index 74d6ae8..52cdba8 100644 --- a/src/psx/web.py +++ b/src/psx/web.py @@ -17,7 +17,7 @@ class DataReader: - headers = ['TIME', 'OPEN', 'HIGH', 'LOW', 'CLOSE', 'VOLUME'] + headers = ['DATE', 'OPEN', 'HIGH', 'LOW', 'CLOSE', 'VOLUME'] def __init__(self): self.__history = "https://dps.psx.com.pk/historical" @@ -78,11 +78,11 @@ def toframe(self, data): cols = [col.getText() for col in row.select("td")] for key, value in zip(self.headers, cols): - if key == "TIME": + if key == "DATE": value = datetime.strptime(value, "%b %d, %Y") stocks[key].append(value) - return pd.DataFrame(stocks, columns=self.headers).set_index("TIME") + return pd.DataFrame(stocks, columns=self.headers).set_index("DATE") def daterange(self, start: date, end: date) -> list: period = end - start