Description
Code Sample, a copy-pastable example if possible
class MyMapping(Mapping):
def __init__(self, content=None):
if content:
self._content = content
else:
self._content = {}
def __getitem__(self, key):
return self._content[key]
def __iter__(self):
return iter(self._content)
def __len__(self):
return len(self._content)
objs = MyMapping({"a": pd.DataFrame({"_0": [0.], "_1": [0.]}), "b": pd.DataFrame({"_0": [0.], "_1": [0.]})}
concat_objs = pd.concat(objs, axis=1)
Problem description
The above code raises a TypeError with the message "cannot concatenate object of type '<class 'str'>'; only Series and DataFrame objs are valid".
As the documentation explicitly specifies that the argument objs
can be a mapping of Series or DataFrame objects, the expected behaviour is to just proceed.
Expected Output
The concatenated data frame.
Output of pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.6.7.final.0
python-bits : 64
OS : Darwin
OS-release : 19.3.0
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : None
LOCALE : en_GB.UTF-8
pandas : 0.25.3
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 19.3.1
setuptools : 41.0.0
Cython : None
pytest : 5.3.2
hypothesis : None
sphinx : 1.8.5
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.3.1
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.1
IPython : 7.12.0
pandas_datareader: None
bs4 : None
bottleneck : 1.2.1
fastparquet : None
gcsfs : None
lxml.etree : 4.3.1
matplotlib : 3.1.3
numexpr : 2.7.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : 3.6.1
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None