Hi!
So I’m still very new to python (taking the google advanced data science certificate and can do some things in python) and while I understand esipy I basically want to take market data and crunch it in numpy, pandas, data frames, etc, but unfamiliar with json and how it relates to data frames and converting it into something I can use. While I understand json files are essentially data strings, so usable as a data frame, when I look at the sample code on esipy’s github page I’m lost how to switch over that to pandas, so it’s probably a simple conversion that my head is overthinking. I’m basically in eve to learn and practice this stuff so while ChatGPT is an option I’d rather learn by doing (though experimenting and breaking code is not my favorite thing to do) and using chat to basically debug and troubleshoot. (Stack overflow is my mortal enemy).
Thanks in advance!
Better question: should I make a variable calling the json data and then import that variable into pandas?
esipy might not be the best solution for your. It is designed to be used with web server and you have a 40 sec load time with each startup to build the swagger client.
If you just want to access one end point you might be better off just doing a normal HTTP request , e.g. with the requests library.
Or you can look into other 3rd party libraries. e.g. there is esi-client, which is has no startup-time and also makes accessing endpoints easier that require tokens.
(Full disclosure I am the author of that library).
Here is an example on how to load the list of factions retrieved from ESI into pandas using esi_client:
from esi_client.api.universe_api import UniverseApi
import pandas as pd
factions = UniverseApi().get_universe_factions()
records = [x.to_dict() for x in factions]
df = pd.DataFrame.from_records(records, index="faction_id")
print(df)
Please note that the objects returned from the client are objects and need to be converted to dictionaries with to_dict()
so that pandas can understand them.
1 Like
Okay that makes sense! Thank you! Definitely needed a smack down of my ego because it was starting to take off from cape canaveral on its mission to Pluto thinking I’ve solved the problem! But #imlearning and I feel embarrassed for it
1 Like
I’m assuming I can load into conda/jypter notebooks? Just use pip?
sure. esi-client is a normal Python library, which you can install with pip. Never tried it with anaconda myself, but it should work.
Please also take a look at the README, which has examples for the most common cases. If you have any questions, I’d be happy to help.
By George, I really did it, I did it, I did it!
1 Like