Intro to Pandas data structures
gregreda.com
gregreda.com
Just one thing to point out regarding the final example: read_csv will actually fetch a URL if it's given as input, so there is no need to use urllib2 and StringIO. Instead, you can just do:
from_url = pd.read_csv('http://www.example.com/data.tsv', sep='\t')
Thanks for pointing this out too - had no idea it'd handle a URL.
One thing I do have a issue with in pandas is the type conversion on sparse data, i.e. a column with missing values. It's a pity you can convert that to a float for example.
myframe['myfield'] = myframe['myfield'].dropna().map(float) myframe.myfield.dropna().astype(float)
I'd need to test that out though - type conversion in pandas/NumPy has always been a little confusing for me.One thing I would point out for new users is the .loc and .iloc functions which I think make selecting data more intuitive because they are a bit more explicit.
from pandasql import sqldf, load_meat, load_births
pysqldf = lambda q: sqldf(q, globals())
meat = load_meat()
births = load_births()
print pysqldf("SELECT * FROM meat LIMIT 10;").head()Damn.
and looks like working for the city of chicago is the thing to do...not bad salaries out there :D