I am trying to read a CSV file into a DataFrame that I can use later in my code for a Leaflet map. Based on the Danfo.js documentation, here's what my code currently looks like:
dfd.readCSV("my_online_csv_file.csv")
.then(df => {
df.describe().print()
}).catch(err => {
console.log(err);
})
This code does indeed output some descriptive stats within my console. However, if I then try to access this DataFrame outside this block via df.head().print();, I get the following error:
Uncaught ReferenceError: df is not defined
I also tried the following setup:
df_data = dfd.readCSV("my_online_csv_file.csv");
df.head().print()
However, this produced the following error:
Uncaught TypeError: df.head is not a function
Is there an easy way for me to both read in a CSV file and access in later in the function? As a newcomer to both JavaScript and Danfo, I feel like I'm missing something very obvious.