Skip to content

BUG: Fix syntax error #629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas_datareader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
get_iex_book, get_iex_symbols, get_last_iex,
get_markets_iex, get_nasdaq_symbols, get_quote_yahoo,
get_recent_iex, get_records_iex, get_summary_iex,
get_tops_iex, get_data_tiingo, get_iex_data_tiingo,
get_tops_iex, get_data_tiingo, get_iex_data_tiingo,
get_data_alphavantage)

__version__ = get_versions()['version']
Expand Down
13 changes: 11 additions & 2 deletions pandas_datareader/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def get_filepath_or_buffer(filepath_or_buffer, encoding=None,
from pandas.util.testing import assertRaisesRegexp as assert_raises_regex
get_filepath_or_buffer = com.get_filepath_or_buffer

if PANDAS_0230:
from pandas.core.dtypes.common import is_list_like
if PANDAS_0190:
from pandas.api.types import is_list_like
else:
from pandas.core.common import is_list_like

Expand All @@ -50,3 +50,12 @@ def get_filepath_or_buffer(filepath_or_buffer, encoding=None,
from urllib.error import HTTPError
else:
from urllib2 import HTTPError


def concat(*args, **kwargs):
"""
Shim to wokr around sort keyword
"""
if not PANDAS_0230 and 'sort' in kwargs:
del kwargs['sort']
return pd.concat(*args, **kwargs)
3 changes: 2 additions & 1 deletion pandas_datareader/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
from pandas_datareader.robinhood import RobinhoodHistoricalReader, \
RobinhoodQuoteReader
from pandas_datareader.stooq import StooqDailyReader
from pandas_datareader.tiingo import TiingoDailyReader, TiingoQuoteReader, TiingoIEXHistoricalReader
from pandas_datareader.tiingo import (TiingoDailyReader, TiingoQuoteReader,
TiingoIEXHistoricalReader)
from pandas_datareader.yahoo.actions import (YahooActionReader, YahooDivReader)
from pandas_datareader.yahoo.components import _get_data as \
get_components_yahoo
Expand Down
2 changes: 1 addition & 1 deletion pandas_datareader/famafrench.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def _read_one_data(self, url, params):

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

df = read_csv(StringIO('Date' + src[start:]), **params)
Expand Down
4 changes: 2 additions & 2 deletions pandas_datareader/moex.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pandas.compat import StringIO

from pandas_datareader.base import _DailyBaseReader
from pandas_datareader.compat import is_list_like
from pandas_datareader.compat import is_list_like, concat


class MoexReader(_DailyBaseReader):
Expand Down Expand Up @@ -170,7 +170,7 @@ def read(self):
self.close()

if len(dfs) > 1:
return pd.concat(dfs, axis=0, join='outer', sort=True)
return concat(dfs, axis=0, join='outer', sort=True)
else:
return dfs[0]

Expand Down
2 changes: 1 addition & 1 deletion pandas_datareader/stooq.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _get_params(self, symbol, country='US'):
if not symbol.startswith('^'):
if len(symbol_parts) == 1:
symbol = ".".join([symbol, country])
elif symbol_parts[1].lower() == 'pl:
elif symbol_parts[1].lower() == 'pl':
symbol = symbol_parts[0]
else:
if symbol_parts[1].lower() not in ['de', 'hk', 'hu', 'jp',
Expand Down
1 change: 1 addition & 0 deletions pandas_datareader/tests/test_stooq.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def test_get_data_stooq_dax():
f = get_data_stooq('^DAX')
assert f.shape[0] > 0


def test_stooq_googl():
f = get_data_stooq('GOOGL.US')
assert f.shape[0] > 0
Expand Down
4 changes: 2 additions & 2 deletions pandas_datareader/tests/yahoo/test_yahoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ def test_yahoo_DataReader(self):
exp.index.name = 'Date'
tm.assert_frame_equal(result.reindex_like(exp).round(5), exp.round(5))


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

Expand Down
4 changes: 3 additions & 1 deletion pandas_datareader/yahoo/actions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from pandas import (concat, DataFrame, MultiIndex)
from pandas import DataFrame, MultiIndex

from pandas_datareader.compat import concat
from pandas_datareader.yahoo.daily import YahooDailyReader


Expand Down
10 changes: 8 additions & 2 deletions pandas_datareader/yahoo/daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,15 @@ def _read_one_data(self, url, params):
prices = prices.join(divs, how='outer')

if 'SPLIT' in types:

def split_ratio(row):
if float(row['Numerator']) > 0:
return eval(row['Splitratio'])
else:
return 1

splits = actions[actions.Type == 'SPLIT'].copy()
splits['SplitRatio'] = splits.apply(
lambda row: eval(row['Splitratio']) if float(row['Numerator'])>0 else 1, axis = 1 )
splits['SplitRatio'] = splits.apply(split_ratio, axis=1)
splits = splits.reset_index(drop=True)
splits = splits.set_index('Date')
splits['Splits'] = splits['SplitRatio']
Expand Down