Skip to content

DOC: fixing override of built-in functions in docs #47632

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
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions doc/source/getting_started/comparison/comparison_with_r.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ with a combination of the ``iloc`` indexer attribute and ``numpy.r_``.

named = list("abcdefg")
n = 30
columns = named + np.arange(len(named), n).tolist()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

columns is not a built-in function. what are you trying to do here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. I am sorry for the mistake. I explained my reasoning in this issue

Could you take a look at it?

Also I was wondering if it was just this file ("comparison_with_r") that was wrong or all of them?

Thanks for the feedback

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented on the issue

df = pd.DataFrame(np.random.randn(n, n), columns=columns)
column_schema = named + np.arange(len(named), n).tolist()
df = pd.DataFrame(np.random.randn(n, n), columns=column_schema)

df.iloc[:, np.r_[:10, 24:30]]

Expand Down
4 changes: 2 additions & 2 deletions doc/source/user_guide/categorical.rst
Original file line number Diff line number Diff line change
Expand Up @@ -626,12 +626,12 @@ even if some categories are not present in the data:

.. ipython:: python

columns = pd.Categorical(
column_schema = pd.Categorical(
["One", "One", "Two"], categories=["One", "Two", "Three"], ordered=True
)
df = pd.DataFrame(
data=[[1, 2, 3], [4, 5, 6]],
columns=pd.MultiIndex.from_arrays([["A", "B", "B"], columns]),
columns=pd.MultiIndex.from_arrays([["A", "B", "B"], column_schema]),
)
df.groupby(axis=1, level=1).sum()

Expand Down
4 changes: 2 additions & 2 deletions doc/source/user_guide/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1171,9 +1171,9 @@ Option 2: read column names and then data
.. ipython:: python

pd.read_csv(StringIO(data), sep=";", header=10, nrows=10).columns
columns = pd.read_csv(StringIO(data), sep=";", header=10, nrows=10).columns
column_schema = pd.read_csv(StringIO(data), sep=";", header=10, nrows=10).columns
pd.read_csv(
StringIO(data), sep=";", index_col=0, header=12, parse_dates=True, names=columns
StringIO(data), sep=";", index_col=0, header=12, parse_dates=True, names=column_schema
)


Expand Down
6 changes: 3 additions & 3 deletions doc/source/user_guide/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -839,10 +839,10 @@ Alternatively, the built-in methods could be used to produce the same outputs.

.. ipython:: python

max = ts.groupby(lambda x: x.year).transform("max")
min = ts.groupby(lambda x: x.year).transform("min")
max_ts = ts.groupby(lambda x: x.year).transform("max")
min_ts = ts.groupby(lambda x: x.year).transform("min")

max - min
max_ts - min_ts

Another common data transform is to replace missing data with the group mean.

Expand Down
4 changes: 2 additions & 2 deletions doc/source/user_guide/indexing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1581,8 +1581,8 @@ The name, if set, will be shown in the console display:
.. ipython:: python

index = pd.Index(list(range(5)), name='rows')
columns = pd.Index(['A', 'B', 'C'], name='cols')
df = pd.DataFrame(np.random.randn(5, 3), index=index, columns=columns)
column_schema = pd.Index(['A', 'B', 'C'], name='cols')
df = pd.DataFrame(np.random.randn(5, 3), index=index, columns=column_schema)
df
df['A']

Expand Down
8 changes: 4 additions & 4 deletions doc/source/user_guide/reshaping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ processed individually.

.. ipython:: python

columns = pd.MultiIndex.from_tuples(
column_schema = pd.MultiIndex.from_tuples(
[
("A", "cat", "long"),
("B", "cat", "long"),
Expand All @@ -188,7 +188,7 @@ processed individually.
],
names=["exp", "animal", "hair_length"],
)
df = pd.DataFrame(np.random.randn(4, 4), columns=columns)
df = pd.DataFrame(np.random.randn(4, 4), columns=column_schema)
df

df.stack(level=["animal", "hair_length"])
Expand All @@ -212,7 +212,7 @@ calling :meth:`~DataFrame.sort_index`, of course). Here is a more complex exampl

.. ipython:: python

columns = pd.MultiIndex.from_tuples(
column_schema = pd.MultiIndex.from_tuples(
[
("A", "cat"),
("B", "dog"),
Expand All @@ -224,7 +224,7 @@ calling :meth:`~DataFrame.sort_index`, of course). Here is a more complex exampl
index = pd.MultiIndex.from_product(
[("bar", "baz", "foo", "qux"), ("one", "two")], names=["first", "second"]
)
df = pd.DataFrame(np.random.randn(8, 4), index=index, columns=columns)
df = pd.DataFrame(np.random.randn(8, 4), index=index, columns=column_schema)
df2 = df.iloc[[0, 1, 2, 4, 5, 7]]
df2

Expand Down
6 changes: 3 additions & 3 deletions doc/source/user_guide/scale.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ Option 1 loads in all the data and then filters to what we need.

.. ipython:: python

columns = ["id_0", "name_0", "x_0", "y_0"]
column_schema = ["id_0", "name_0", "x_0", "y_0"]

pd.read_parquet("timeseries_wide.parquet")[columns]
pd.read_parquet("timeseries_wide.parquet")[column_schema]

Option 2 only loads the columns we request.

.. ipython:: python

pd.read_parquet("timeseries_wide.parquet", columns=columns)
pd.read_parquet("timeseries_wide.parquet", columns=column_schema)

.. ipython:: python
:suppress:
Expand Down