You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How can I read a CSV file into a persistent DataFrame that can be used later in my script? #686
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:
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:
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.
I now realize that one workaround is to use Pandas to export my data to a .json file (with orient = records specified in to_json()); copy and paste this .json data into my code editor; specify it as a variable; and then run df = new dfd.DataFrame(state_json_data) as specified in the quickstart. This setup allows me to get the expected result when I call df.head(5).print().
Activity
kburchfiel commentedon Jan 8, 2026
I now realize that one workaround is to use Pandas to export my data to a .json file (with
orient = recordsspecified into_json()); copy and paste this .json data into my code editor; specify it as a variable; and then rundf = new dfd.DataFrame(state_json_data)as specified in the quickstart. This setup allows me to get the expected result when I calldf.head(5).print().