Skip to content

DOC: need SQL -> pandas tips #4524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jreback opened this issue Aug 9, 2013 · 12 comments
Closed

DOC: need SQL -> pandas tips #4524

jreback opened this issue Aug 9, 2013 · 12 comments
Labels
Docs IO SQL to_sql, read_sql, read_sql_query
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Aug 9, 2013

of course #4164 makes this syntax easier anyhow

Here's an example of the types of things we need (obviously not all apply here)
http://www.pytables.org/moin/HintsForSQLUsers

we have this in the docs for join/merge, but maybe useful for:

  • groupby
  • boolean indexing to replace select

e.g.

select * from mytables where A='bar' and B>to_date('20130101')

replaced by:

df[(df.A=='bar') & (df.B>Timestamp('20130101'))

select count(*) from mytables

replaced by

len(df)

etc

@hayd
Copy link
Contributor

hayd commented Aug 9, 2013

Where were you thinking this should go?

Perhaps could add to/rename the R comparison section cc #3980

Although tbh not sure what purpose of that section actually is, perhaps slightly different? But if it was syntax/idiom differences:

pandas for R users
pandas for SQL users

seem like they should be in the same section.

@cpcloud
Copy link
Member

cpcloud commented Aug 9, 2013

actually you should be able to do df["A == 'bar' and B > 20130101"] ftw.

@jreback
Copy link
Contributor Author

jreback commented Aug 9, 2013

yes....syntax differences is a better title....maybe a How To section?

e.g. say you are from a SQL backgroud, how to do '......' in pandas?

@RomanPekar
Copy link
Contributor

I think I could try to find some SQL popular / tricky examples and compare it to pandas, where I should put these comparisons? I still don't have good pandas solution for some SQL queries, but it'll be interesting to find it

@jreback
Copy link
Contributor Author

jreback commented Oct 29, 2013

interesting reference

http://johnbeieler.org/blog/2013/06/06/using-sql/

@ghost
Copy link

ghost commented Oct 30, 2013

Here is a notebook you guys can use if you are short in time.

Link

@jtratner
Copy link
Contributor

I thought this was a nice intro - ttp://www.gregreda.com/2013/10/26/intro-to-pandas-data-structures/ (by @gjreda)

@gjreda
Copy link
Contributor

gjreda commented Nov 1, 2013

Looks interesting - what'd you have in mind, @jtratner, @jreback? I'd be happy to restructure or contribute the tutorial as much as possible.

@jtratner
Copy link
Contributor

jtratner commented Nov 1, 2013

I like how your intro gets through key features (like I/O) in a very human way that's easy to follow. That said, I'm not sure there's a good fit for that sort of thing in the docs (10 minutes to pandas is somewhat like that, though less conversational), but the later parts where you take an SQL statement and convert it into what you'd use in pandas could be a nice fit, especially with your explanation. That plus some of the notes from @pichonz could be a nice foundation for a SQL:pandas 'cheat sheet'.

Also, if you have any suggestions for edits to the docs, those are always welcome!

@gjreda
Copy link
Contributor

gjreda commented Nov 5, 2013

Sounds good. I'll try to add some stuff over the next week or two.

@jtratner
Copy link
Contributor

jtratner commented Nov 5, 2013

Great!

gjreda added a commit to gjreda/pandas that referenced this issue Dec 6, 2013
jreback added a commit that referenced this issue Dec 7, 2013
DOC: SQL to pandas comparison (#4524)
@jorisvandenbossche
Copy link
Member

After PR #5615 this can be closed?

@jreback jreback closed this as completed Dec 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs IO SQL to_sql, read_sql, read_sql_query
Projects
None yet
Development

No branches or pull requests

7 participants