How to append data to an empty DataFrame in Pandas?

How to append data to an empty DataFrame in Pandas?

Asked on December 14, 2018 in Pandas.
Add Comment


  • 2 Answer(s)

    This may work :

    >>> df = pd.DataFrame()
    >>> data = pd.DataFrame({"A": range(3)})
    >>> df.append(data)
       A
    0  0
    1  1
    2  2
    

    If append function work,  save the output :

    >>> df
    Empty DataFrame
    Columns: []
    Index: []
    >>> df = df.append(data)
    >>> df
       A
    0  0
    1  1
    2  2
    
    Answered on December 14, 2018.
    Add Comment

    To concatenate the data, you can use this.,

    InfoDF = pd.DataFrame()
    tempDF = pd.DataFrame(rows,columns=['id','min_date'])
    InfoDF = pd.concat([InfoDF,tempDF])
    
    Answered on December 14, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.