Returning a dataframe in python function

前端 未结 4 1933
-上瘾入骨i
-上瘾入骨i 2021-02-05 21:03

I am trying to create and return a data frame from a python function

def create_df():
    data = {\'state\': [\'Ohio\',\'Ohio\',\'Ohio\',\'Nevada\',\'Nevada\'],         


        
4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-05 21:11

    when you call create_df() python calls the function but doesn't save the result in any variable. that is why you got the error.

    assign the result of create_df() to df like this df = create_df()

提交回复
热议问题