Return two data frames from a function with data frame format

后端 未结 1 733
野的像风
野的像风 2021-01-11 21:39

I want to return two data frames from a function, like this:

def test():
    df1 = pd.DataFrame([1,2,3], [\'a\',\'b\',\'c\'])
    df2 = pd.DataFrame([4,5,6],         


        
相关标签:
1条回答
  • 2021-01-11 22:20

    How about this:

    def test():
        df1 = pd.DataFrame([1,2,3], ['a','b','c'])
        df2 = pd.DataFrame([4,5,6], ['d','e','f'])
        return df1, df2
    
    a, b = test()
    display(a, b)
    

    This prints out:

        0
    a   1
    b   2
    c   3
    
        0
    d   4
    e   5
    f   6
    
    0 讨论(0)
提交回复
热议问题