I am trying to create and return a data frame from a python function
def create_df(): data = {\'state\': [\'Ohio\',\'Ohio\',\'Ohio\',\'Nevada\',\'Nevada\'],
You can return dataframe from a function by making a copy of the dataframe like
def my_function(dataframe): my_df=dataframe.copy() my_df=my_df.drop(0) return(my_df) new_df=my_function(old_df) print(type(new_df))
Output: pandas.core.frame.DataFrame