I have a django app, which allows the user to upload a csv file, say a csv file of rankings of universities. I'd have to process the data that has been uploaded. For example, grey out any column which has string values and calculate the mean and std. deviation of all the values of a column. For this, I am using Pandas and converting the csv file to a pandas dataframe.
How do I display the dataset from the csv file using django? The column names cannot be hard coded because the user may upload any csv file. I checked django-tables2 and did the following
csvfile = request.FILES['csv_file']
data = pd.read_csv(csvfile.name)
context = {'loaded_data': data}
return render(request, "dataflow/table.html", context)
but I get the error ValueError: Expected table or queryset, not DataFrame
AttributeError: 'DataFrame' object has no attribute 'as_dict'
– Agrology