Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions doc/source/getting_started/comparison/comparison_with_sql.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ With pandas, column selection is done by passing a list of column names to your
Calling the DataFrame without the list of column names would display all columns (akin to SQL's
``*``).

In SQL, you can add a calculated column:

.. code-block:: sql

SELECT *, tip/total_bill as tip_rate
FROM tips
LIMIT 5;

With pandas, you can use the assign() method of a DataFrame to append a new column:

.. ipython:: python

tips.assign(tip_rate = tips['tip'] / tips['total_bill']).head(5)

WHERE
-----
Filtering in SQL is done via a WHERE clause.
Expand Down