Skip to content

Commit

Permalink
fix: read --columns filters output.
Browse files Browse the repository at this point in the history
  • Loading branch information
timcera committed Nov 23, 2020
1 parent a3edf4c commit 7b8d137
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tstoolbox/functions/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ def read(
),
start_date=start_date,
end_date=end_date,
pick=columns,
round_index=round_index,
dropna=dropna,
force_freq=force_freq,
Expand All @@ -171,6 +170,8 @@ def read(
if append != "combine":
result = pd.concat(result_list, axis=append)

result = tsutils._pick(result, columns)

result.sort_index(inplace=True)

return result
Expand Down
5 changes: 4 additions & 1 deletion tstoolbox/tsutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,10 @@ def _pick(tsd, columns):
# Use the -1 marker to indicate index
jtsd = pd.DataFrame(tsd.index, index=tsd.index)
else:
jtsd = pd.DataFrame(tsd[tsd.columns[col]], index=tsd.index)
try:
jtsd = pd.DataFrame(tsd.iloc[:, col], index=tsd.index)
except IndexError:
jtsd = pd.DataFrame(tsd.loc[:, col], index=tsd.index)

newtsd = newtsd.join(jtsd, lsuffix="_{0}".format(index), how="outer")
return newtsd
Expand Down

0 comments on commit 7b8d137

Please sign in to comment.