Skip to content

Commit b2ee60b

Browse files
authored
Merge pull request #629 from bashtage/syntax-error
BUG: Fix syntax error
2 parents 7522f75 + 3583366 commit b2ee60b

File tree

10 files changed

+32
-13
lines changed

10 files changed

+32
-13
lines changed

pandas_datareader/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
get_iex_book, get_iex_symbols, get_last_iex,
77
get_markets_iex, get_nasdaq_symbols, get_quote_yahoo,
88
get_recent_iex, get_records_iex, get_summary_iex,
9-
get_tops_iex, get_data_tiingo, get_iex_data_tiingo,
9+
get_tops_iex, get_data_tiingo, get_iex_data_tiingo,
1010
get_data_alphavantage)
1111

1212
__version__ = get_versions()['version']

pandas_datareader/compat/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def get_filepath_or_buffer(filepath_or_buffer, encoding=None,
4040
from pandas.util.testing import assertRaisesRegexp as assert_raises_regex
4141
get_filepath_or_buffer = com.get_filepath_or_buffer
4242

43-
if PANDAS_0230:
44-
from pandas.core.dtypes.common import is_list_like
43+
if PANDAS_0190:
44+
from pandas.api.types import is_list_like
4545
else:
4646
from pandas.core.common import is_list_like
4747

@@ -50,3 +50,12 @@ def get_filepath_or_buffer(filepath_or_buffer, encoding=None,
5050
from urllib.error import HTTPError
5151
else:
5252
from urllib2 import HTTPError
53+
54+
55+
def concat(*args, **kwargs):
56+
"""
57+
Shim to wokr around sort keyword
58+
"""
59+
if not PANDAS_0230 and 'sort' in kwargs:
60+
del kwargs['sort']
61+
return pd.concat(*args, **kwargs)

pandas_datareader/data.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
from pandas_datareader.robinhood import RobinhoodHistoricalReader, \
2828
RobinhoodQuoteReader
2929
from pandas_datareader.stooq import StooqDailyReader
30-
from pandas_datareader.tiingo import TiingoDailyReader, TiingoQuoteReader, TiingoIEXHistoricalReader
30+
from pandas_datareader.tiingo import (TiingoDailyReader, TiingoQuoteReader,
31+
TiingoIEXHistoricalReader)
3132
from pandas_datareader.yahoo.actions import (YahooActionReader, YahooDivReader)
3233
from pandas_datareader.yahoo.components import _get_data as \
3334
get_components_yahoo

pandas_datareader/famafrench.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def _read_one_data(self, url, params):
106106

107107
datasets, table_desc = {}, []
108108
for i, src in enumerate(tables):
109-
match = re.search('^\s*,', src, re.M) # the table starts there
109+
match = re.search(r'^\s*,', src, re.M) # the table starts there
110110
start = 0 if not match else match.start()
111111

112112
df = read_csv(StringIO('Date' + src[start:]), **params)

pandas_datareader/moex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pandas.compat import StringIO
77

88
from pandas_datareader.base import _DailyBaseReader
9-
from pandas_datareader.compat import is_list_like
9+
from pandas_datareader.compat import is_list_like, concat
1010

1111

1212
class MoexReader(_DailyBaseReader):
@@ -170,7 +170,7 @@ def read(self):
170170
self.close()
171171

172172
if len(dfs) > 1:
173-
return pd.concat(dfs, axis=0, join='outer', sort=True)
173+
return concat(dfs, axis=0, join='outer', sort=True)
174174
else:
175175
return dfs[0]
176176

pandas_datareader/stooq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def _get_params(self, symbol, country='US'):
4040
if not symbol.startswith('^'):
4141
if len(symbol_parts) == 1:
4242
symbol = ".".join([symbol, country])
43-
elif symbol_parts[1].lower() == 'pl:
43+
elif symbol_parts[1].lower() == 'pl':
4444
symbol = symbol_parts[0]
4545
else:
4646
if symbol_parts[1].lower() not in ['de', 'hk', 'hu', 'jp',

pandas_datareader/tests/test_stooq.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def test_get_data_stooq_dax():
2626
f = get_data_stooq('^DAX')
2727
assert f.shape[0] > 0
2828

29+
2930
def test_stooq_googl():
3031
f = get_data_stooq('GOOGL.US')
3132
assert f.shape[0] > 0

pandas_datareader/tests/yahoo/test_yahoo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ def test_yahoo_DataReader(self):
278278
exp.index.name = 'Date'
279279
tm.assert_frame_equal(result.reindex_like(exp).round(5), exp.round(5))
280280

281-
282-
# test cases with "1/0" split ratio in actions- no split, just chnage symbol from POT to NTR
281+
# test cases with "1/0" split ratio in actions -
282+
# no split, just chnage symbol from POT to NTR
283283
start = datetime(2017, 12, 30)
284284
end = datetime(2018, 12, 30)
285285

pandas_datareader/yahoo/actions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from pandas import (concat, DataFrame, MultiIndex)
1+
from pandas import DataFrame, MultiIndex
2+
3+
from pandas_datareader.compat import concat
24
from pandas_datareader.yahoo.daily import YahooDailyReader
35

46

pandas_datareader/yahoo/daily.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,15 @@ def _read_one_data(self, url, params):
173173
prices = prices.join(divs, how='outer')
174174

175175
if 'SPLIT' in types:
176+
177+
def split_ratio(row):
178+
if float(row['Numerator']) > 0:
179+
return eval(row['Splitratio'])
180+
else:
181+
return 1
182+
176183
splits = actions[actions.Type == 'SPLIT'].copy()
177-
splits['SplitRatio'] = splits.apply(
178-
lambda row: eval(row['Splitratio']) if float(row['Numerator'])>0 else 1, axis = 1 )
184+
splits['SplitRatio'] = splits.apply(split_ratio, axis=1)
179185
splits = splits.reset_index(drop=True)
180186
splits = splits.set_index('Date')
181187
splits['Splits'] = splits['SplitRatio']

0 commit comments

Comments
 (0)