I'm trying to create a function that takes a CSV input but when I try to input a csv like
function('sample.csv')
it only views the input as a string.
I'm trying to create a function that takes a CSV input but when I try to input a csv like
function('sample.csv')
it only views the input as a string.
You're referencing a string in the function. You need to read the CSV file and then use it as an argument. With pandas it can be done as follows:
import pandas as pd
df = pd.read_csv('sample.csv')
function(df)
If I understood correctly what you're trying to do, something like this should do the trick:
import pandas as pd
def myfunc(csv_path):
df = pd.read_csv(csv_path)
return df
myfunc('sample.csv')