@@ -0,0 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Merge pull request #2832 from dokson/fix/download-index-name ([#2832]()) (1df338c)
|
||||
- Preserve Date/Datetime index name in yf.download() output (c3db565)
|
||||
- Merge pull request #2830 from ranaroussi/main ([#2830]()) (754346f)
|
||||
- Version 1.4.0 (e005d2d)
|
||||
- Merge pull request #2828 from ranaroussi/dev ([#2828]()) (ff36bd7)
|
||||
- Merge pull request #2829 from ranaroussi/dependabot/github_actions/zizmorcore/zizmor-action-0.5.6 ([#2829]()) (44cc9ba)
|
||||
- Bump zizmorcore/zizmor-action from 0.5.3 to 0.5.6 (89ad803)
|
||||
|
||||
@@ -324,6 +324,8 @@ class TestTickerHistory(unittest.TestCase):
|
||||
interval=interval, progress=False)
|
||||
self.assertIsInstance(data, pd.DataFrame, "data has wrong type")
|
||||
self.assertFalse(data.empty, "data is empty")
|
||||
expected_name = 'Datetime' if interval[-1] in ('m', 'h') else 'Date'
|
||||
self.assertEqual(data.index.name, expected_name)
|
||||
if ignore_tz:
|
||||
self.assertIsNone(data.index.tz)
|
||||
else:
|
||||
|
||||
+6
-5
@@ -214,7 +214,7 @@ def _download_impl(ctx, tickers, start=None, end=None, actions=False, threads=Tr
|
||||
keys=ctx.dfs.keys(), names=['Ticker', 'Price'])
|
||||
data.rename(columns=ctx.isins, inplace=True)
|
||||
|
||||
if group_by == 'column':
|
||||
if group_by == 'column' and isinstance(data.columns, _pd.MultiIndex):
|
||||
data.columns = data.columns.swaplevel(0, 1)
|
||||
data.sort_index(level=0, axis=1, inplace=True)
|
||||
|
||||
@@ -240,11 +240,12 @@ def reindex_dfs(dfs, ignore_tz):
|
||||
if (dfs[tkr] is not None) and (not dfs[tkr].empty):
|
||||
dfs[tkr].index = dfs[tkr].index.tz_convert(tz_mode)
|
||||
|
||||
all_indices = set()
|
||||
idx = None
|
||||
for df in dfs.values():
|
||||
all_indices.update(df.index)
|
||||
idx = sorted(all_indices)
|
||||
idx = _pd.to_datetime(idx)
|
||||
if df is not None and not df.empty:
|
||||
idx = df.index if idx is None else idx.union(df.index)
|
||||
if idx is None:
|
||||
idx = _pd.DatetimeIndex([])
|
||||
for key, df in dfs.items():
|
||||
dfs[key] = df.reindex(idx)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user