loganhotz / edan

economic data analysis toolkit, with an emphasis on NIPA accounts and BLS labor aggregates
0 stars 0 forks source link

BUG: when an iterable is passed to the `method` parameter in NIPA/CPI Plot Accessor, an error is thrown #11

Closed loganhotz closed 3 years ago

loganhotz commented 3 years ago

after commit 8c8aa009ce8fec3b5d5a8de9d09ed6030ba479af, which allows for passing an iterable of methods to the base TransformationAccessor, the method parameter of plot accessors can accept multiple transforms. the calculation is done correctly in the plotting method, but when trying to match the data and column names, an error is thrown. for example,

ax = pce.plot(method=('yryr%', 'difa%'), subs=False)
edan.plot.show()

raises the error

Traceback (most recent call last):
  File "/Users/loganhotz/code/python/projects/edan-dev/attempt.py", line 23, in <module>
    pce.plot(method=('yryr%', 'difa%'), subs=False)
  File "/Users/loganhotz/code/python/projects/edan-dev/edan/plotting/nipa.py", line 382, in __call__
    df.columns = series_names
  File "/Users/loganhotz/code/python/projects/edan-dev/venv/lib/python3.9/site-packages/pandas/core/generic.py", line 5478, in __setattr__
    return object.__setattr__(self, name, value)
  File "pandas/_libs/properties.pyx", line 66, in pandas._libs.properties.AxisProperty.__set__
  File "/Users/loganhotz/code/python/projects/edan-dev/venv/lib/python3.9/site-packages/pandas/core/generic.py", line 670, in _set_axis
    self._mgr.set_axis(axis, labels)
  File "/Users/loganhotz/code/python/projects/edan-dev/venv/lib/python3.9/site-packages/pandas/core/internals/managers.py", line 220, in set_axis
    raise ValueError(
ValueError: Length mismatch: Expected axis has 2 elements, new values have 1 elements
loganhotz commented 3 years ago

Addressed with commit e1e3bc1ade71610365e478ba65f0c033a0f56ad1