mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-31 12:10:31 +08:00
MAINT: Update fetcher for pandas 0.18.
- Remove support for usecols=[]. - Use sort_values instead of sort(). - Use errors='coerce' instead of coerce=True.
This commit is contained in:
+2
-24
@@ -297,7 +297,6 @@ def handle_data(context, data):
|
||||
|
||||
@parameterized.expand([("unspecified", ""),
|
||||
("none", "usecols=None"),
|
||||
("empty", "usecols=[]"),
|
||||
("without date", "usecols=['Value']"),
|
||||
("with date", "usecols=('Value', 'Date')")])
|
||||
def test_usecols(self, testname, usecols):
|
||||
@@ -325,30 +324,9 @@ def initialize(context):
|
||||
context.stocks = [sid(3766), sid(25317)]
|
||||
|
||||
def handle_data(context, data):
|
||||
if {should_have_data}:
|
||||
try:
|
||||
data.current("urban", "cpi")
|
||||
except (KeyError, ValueError):
|
||||
assert False
|
||||
else:
|
||||
try:
|
||||
data.current("urban", "cpi")
|
||||
except (KeyError, ValueError):
|
||||
assert True
|
||||
data.current("urban", "cpi")
|
||||
"""
|
||||
|
||||
results = self.run_algo(
|
||||
code.format(
|
||||
usecols=usecols,
|
||||
should_have_data=testname in [
|
||||
'none',
|
||||
'unspecified',
|
||||
'without date',
|
||||
'with date',
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
results = self.run_algo(code.format(usecols=usecols))
|
||||
# 251 trading days in 2006
|
||||
self.assertEqual(len(results), 251)
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ class PandasCSV(with_metaclass(ABCMeta, object)):
|
||||
date_str_series.values,
|
||||
format=format_str,
|
||||
utc=True,
|
||||
coerce=True,
|
||||
errors='coerce',
|
||||
)
|
||||
else:
|
||||
parsed = pd.to_datetime(
|
||||
@@ -301,7 +301,7 @@ class PandasCSV(with_metaclass(ABCMeta, object)):
|
||||
df['sid'] = self.symbol
|
||||
elif self.finder:
|
||||
|
||||
df.sort(self.symbol_column)
|
||||
df.sort_values(by=self.symbol_column, inplace=True)
|
||||
|
||||
# Pop the 'sid' column off of the DataFrame, just in case the user
|
||||
# has assigned it, and throw a warning
|
||||
|
||||
Reference in New Issue
Block a user