Skip to content

Clearer error message for pd.concat if empty iterator is passed #9157

Closed
@cel4

Description

@cel4

I just saw following problem on stackoverflow: http://stackoverflow.com/questions/27665560/concatenating-files-with-python-pandas

It is not possible to concatenate an empty sequence of data frames.

This tiny code fragment

import pandas as pd
dfs = []
pd.concat(dfs)

Throws following error:

/Users/ch/miniconda/envs/sci33/lib/python3.3/site-packages/pandas/tools/merge.py in __init__(self, objs, axis, join, join_axes, keys, levels, names, ignore_index, verify_integrity, copy)
    765 
    766         if len(objs) == 0:
--> 767             raise ValueError('All objects passed were None')
    768 
    769         # consolidate data & figure out what our result ndim is going to be

ValueError: All objects passed were None

I would suggest catching this special case in pd.concat before trying to merge and to raise an error with a clearer error description. For this special case, the current error message is not very helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Error ReportingIncorrect or improved errors from pandasReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions