From 837f48bfe8b928635e93bf82086ecfd76275a83f Mon Sep 17 00:00:00 2001 From: Thinh Vu <39723360+thinh-vu@users.noreply.github.com> Date: Tue, 9 Jul 2024 11:28:00 +0700 Subject: [PATCH] Update trading.py --- vnstock3/explorer/vci/trading.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vnstock3/explorer/vci/trading.py b/vnstock3/explorer/vci/trading.py index ed4400c1..487ebbff 100644 --- a/vnstock3/explorer/vci/trading.py +++ b/vnstock3/explorer/vci/trading.py @@ -77,7 +77,9 @@ def price_board (self, symbols_list: List[str], to_df:Optional[bool]=True, show_ drop_columns = [('bid_ask', 'code'), ('bid_ask', 'symbol'), ('bid_ask', 'session'), ('bid_ask', 'received_time'), ('bid_ask', 'message_type'), ('bid_ask', 'time'), ('bid_ask', 'bid_prices'), ('bid_ask', 'ask_prices'), ('listing', 'code'), ('listing', 'exercise_price'), ('listing', 'exercise_ratio'), ('listing', 'maturity_date'), ('listing', 'underlying_symbol'), ('listing', 'issuer_name'), ('listing', 'received_time'), ('listing', 'message_type'), ('listing', 'en_organ_name'), ('listing', 'en_organ_short_name'), ('listing', 'organ_short_name'), ('listing', 'ticker'), ('match', 'code'), ('match', 'symbol'), ('match', 'received_time'), ('match', 'message_type'), ('match', 'time'), ('match', 'session')] - combine_df = combine_df.drop(columns=drop_columns) + + # Drop columns only if they exist in the DataFrame + combine_df = combine_df.drop(columns=[col for col in drop_columns if col in combine_df.columns]) # rename column for board inside listing to exchange combine_df = combine_df.rename(columns={'board': 'exchange'}, level=1) @@ -86,4 +88,4 @@ def price_board (self, symbols_list: List[str], to_df:Optional[bool]=True, show_ if to_df: return combine_df else: - return data \ No newline at end of file + return data