From 5fa28a85d520a99cd81685b13de5c2a4f3d26352 Mon Sep 17 00:00:00 2001 From: Chang Lan Date: Mon, 15 Feb 2021 17:28:23 -0800 Subject: [PATCH 1/3] Deduplicate rows with the same index --- pandas_datareader/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas_datareader/base.py b/pandas_datareader/base.py index 4d4148df..f2cbd5b4 100644 --- a/pandas_datareader/base.py +++ b/pandas_datareader/base.py @@ -265,7 +265,10 @@ def _dl_mult_symbols(self, symbols): for sym_group in _in_chunks(symbols, self.chunksize): for sym in sym_group: try: - stocks[sym] = self._read_one_data(self.url, self._get_params(sym)) + df = self._read_one_data(self.url, self._get_params(sym)) + # Keep the last item if there are duplicated rows with the same index. + df = df[~df.index.duplicated(keep='last')] + stocks[sym] = df passed.append(sym) except (IOError, KeyError): msg = "Failed to read symbol: {0!r}, replacing with NaN." From 87bc3f815caba6c32882138a692d9db634252c83 Mon Sep 17 00:00:00 2001 From: Chang Lan Date: Mon, 15 Feb 2021 17:31:14 -0800 Subject: [PATCH 2/3] reformat by black --- pandas_datareader/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas_datareader/base.py b/pandas_datareader/base.py index f2cbd5b4..cbec8e85 100644 --- a/pandas_datareader/base.py +++ b/pandas_datareader/base.py @@ -139,7 +139,7 @@ def _sanitize_response(response): return response.content def _get_response(self, url, params=None, headers=None): - """ send raw HTTP request to get requests.Response from the specified url + """send raw HTTP request to get requests.Response from the specified url Parameters ---------- url : str @@ -267,7 +267,7 @@ def _dl_mult_symbols(self, symbols): try: df = self._read_one_data(self.url, self._get_params(sym)) # Keep the last item if there are duplicated rows with the same index. - df = df[~df.index.duplicated(keep='last')] + df = df[~df.index.duplicated(keep="last")] stocks[sym] = df passed.append(sym) except (IOError, KeyError): From 1a551dc8a663b379eba6aa3ce9b2c9639c646713 Mon Sep 17 00:00:00 2001 From: Chang Lan Date: Mon, 15 Feb 2021 17:35:09 -0800 Subject: [PATCH 3/3] Update change log --- docs/source/whatsnew/v0.9.1.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/source/whatsnew/v0.9.1.txt b/docs/source/whatsnew/v0.9.1.txt index 3ec1cb44..f78eaad3 100644 --- a/docs/source/whatsnew/v0.9.1.txt +++ b/docs/source/whatsnew/v0.9.1.txt @@ -20,13 +20,15 @@ Enhancements from every trading board (ver. 0.9.0 behaviour) - Docs for MOEX reedited -.. _whatsnew_080.bug_fixes: +.. _whatsnew_091.bug_fixes: Bug Fixes ~~~~~~~~~ - Fixed broken links on the github ussies on "What’s New" docs pages +- Deduplicate rows with the same index (:issue:`610`) (:issue:`738`) Contributors ~~~~~~~~~~~~ -- Dmitry Alekseev \ No newline at end of file +- Dmitry Alekseev +- Chang Lan \ No newline at end of file