-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: create shared includes for comparison docs, take III #38887
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
doc/source/getting_started/comparison/includes/construct_dataframe.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
A pandas ``DataFrame`` can be constructed in many different ways, | ||
but for a small number of values, it is often convenient to specify it as | ||
a Python dictionary, where the keys are the column names | ||
and the values are the data. | ||
|
||
.. ipython:: python | ||
|
||
df = pd.DataFrame({"x": [1, 3, 5], "y": [2, 4, 6]}) | ||
df |
16 changes: 16 additions & 0 deletions
16
doc/source/getting_started/comparison/includes/filtering.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
DataFrames can be filtered in multiple ways; the most intuitive of which is using | ||
:ref:`boolean indexing <indexing.boolean>` | ||
|
||
.. ipython:: python | ||
|
||
tips[tips["total_bill"] > 10] | ||
|
||
The above statement is simply passing a ``Series`` of ``True``/``False`` objects to the DataFrame, | ||
returning all rows with ``True``. | ||
|
||
.. ipython:: python | ||
|
||
is_dinner = tips["time"] == "Dinner" | ||
is_dinner | ||
is_dinner.value_counts() | ||
tips[is_dinner] |
12 changes: 12 additions & 0 deletions
12
doc/source/getting_started/comparison/includes/if_then.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
The same operation in pandas can be accomplished using | ||
the ``where`` method from ``numpy``. | ||
|
||
.. ipython:: python | ||
|
||
tips["bucket"] = np.where(tips["total_bill"] < 10, "low", "high") | ||
tips.head() | ||
|
||
.. ipython:: python | ||
:suppress: | ||
|
||
tips = tips.drop("bucket", axis=1) |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Python determines the length of a character string with the ``len`` function. | ||
In Python 3, all strings are Unicode strings. ``len`` includes trailing blanks. | ||
Use ``len`` and ``rstrip`` to exclude trailing blanks. | ||
|
||
.. ipython:: python | ||
|
||
tips["time"].str.len().head() | ||
tips["time"].str.rstrip().str.len().head() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pandas objects have a :meth:`DataFrame.sort_values` method, which | ||
takes a list of columns to sort by. | ||
|
||
.. ipython:: python | ||
|
||
tips = tips.sort_values(["sex", "total_bill"]) | ||
tips.head() |
22 changes: 22 additions & 0 deletions
22
doc/source/getting_started/comparison/includes/time_date.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.. ipython:: python | ||
|
||
tips["date1"] = pd.Timestamp("2013-01-15") | ||
tips["date2"] = pd.Timestamp("2015-02-15") | ||
tips["date1_year"] = tips["date1"].dt.year | ||
tips["date2_month"] = tips["date2"].dt.month | ||
tips["date1_next"] = tips["date1"] + pd.offsets.MonthBegin() | ||
tips["months_between"] = tips["date2"].dt.to_period("M") - tips[ | ||
"date1" | ||
].dt.to_period("M") | ||
|
||
tips[ | ||
["date1", "date2", "date1_year", "date2_month", "date1_next", "months_between"] | ||
].head() | ||
|
||
.. ipython:: python | ||
:suppress: | ||
|
||
tips = tips.drop( | ||
["date1", "date2", "date1_year", "date2_month", "date1_next", "months_between"], | ||
axis=1, | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,10 @@ ignore = E203, # space before : (needed for how black formats slicing) | |
E711, # comparison to none should be 'if cond is none:' | ||
|
||
exclude = | ||
doc/source/development/contributing_docstring.rst | ||
doc/source/development/contributing_docstring.rst, | ||
# work around issue of undefined variable warnings | ||
# https://github.com/pandas-dev/pandas/pull/38837#issuecomment-752884156 | ||
doc/source/getting_started/comparison/includes/*.rst | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per suggestion in #38837 (comment). |
||
|
||
[tool:pytest] | ||
# sync minversion with setup.cfg & install.rst | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are any of these shared across compraisons? its not big deal, but you can simply re-use them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, what do you mean by "these"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh it looks like you are doing what i thought (e.g. putting includes in a common location) and then using for comparison_excel/sas/r etc. which is great.
so nvm