Skip to content

Commit fed8144

Browse files
authored
Merge pull request #66 from pandas-dev/master
Sync Fork from Upstream Repo
2 parents 0c1872b + 1d18e95 commit fed8144

28 files changed

+592
-529
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,39 @@ jobs:
154154
echo "region = BHS" >> $RCLONE_CONFIG_PATH
155155
if: github.event_name == 'push'
156156

157-
- name: Sync web
157+
- name: Sync web with OVH
158158
run: rclone sync pandas_web ovh_cloud_pandas_web:dev
159159
if: github.event_name == 'push'
160+
161+
- name: Create git repo to upload the built docs to GitHub pages
162+
run: |
163+
cd pandas_web
164+
git init
165+
touch .nojekyll
166+
echo "dev.pandas.io" > CNAME
167+
printf "User-agent: *\nDisallow: /" > robots.txt
168+
git add --all .
169+
git config user.email "[email protected]"
170+
git config user.name "pandas-bot"
171+
git commit -m "pandas web and documentation in master"
172+
if: github.event_name == 'push'
173+
174+
# For this task to work, next steps are required:
175+
# 1. Generate a pair of private/public keys (i.e. `ssh-keygen -t rsa -b 4096 -C "[email protected]"`)
176+
# 2. Go to https://github.com/pandas-dev/pandas/settings/secrets
177+
# 3. Click on "Add a new secret"
178+
# 4. Name: "github_pagas_ssh_key", Value: <Content of the private ssh key>
179+
# 5. The public key needs to be upladed to https://github.com/pandas-dev/pandas-dev.github.io/settings/keys
180+
- name: Install GitHub pages ssh deployment key
181+
uses: shimataro/ssh-key-action@v2
182+
with:
183+
key: ${{ secrets.github_pages_ssh_key }}
184+
known_hosts: 'github.com,192.30.252.128 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=='
185+
if: github.event_name == 'push'
186+
187+
- name: Publish web and docs to GitHub pages
188+
run: |
189+
cd pandas_web
190+
git remote add origin [email protected]:pandas-dev/pandas-dev.github.io.git
191+
git push -f origin master || true
192+
if: github.event_name == 'push'

azure-pipelines.yml

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -15,78 +15,3 @@ jobs:
1515
parameters:
1616
name: Windows
1717
vmImage: vs2017-win2016
18-
19-
- job: 'Web_and_Docs'
20-
pool:
21-
vmImage: ubuntu-16.04
22-
timeoutInMinutes: 90
23-
steps:
24-
- script: |
25-
echo '##vso[task.setvariable variable=ENV_FILE]environment.yml'
26-
echo '##vso[task.prependpath]$(HOME)/miniconda3/bin'
27-
displayName: 'Setting environment variables'
28-
29-
- script: |
30-
sudo apt-get install -y libc6-dev-i386
31-
ci/setup_env.sh
32-
displayName: 'Setup environment and build pandas'
33-
34-
- script: |
35-
source activate pandas-dev
36-
python web/pandas_web.py web/pandas --target-path=web/build
37-
displayName: 'Build website'
38-
39-
- script: |
40-
source activate pandas-dev
41-
# Next we should simply have `doc/make.py --warnings-are-errors`, everything else is required because the ipython directive doesn't fail the build on errors (https://github.com/ipython/ipython/issues/11547)
42-
doc/make.py --warnings-are-errors | tee sphinx.log ; SPHINX_RET=${PIPESTATUS[0]}
43-
grep -B1 "^<<<-------------------------------------------------------------------------$" sphinx.log ; IPY_RET=$(( $? != 1 ))
44-
exit $(( $SPHINX_RET + $IPY_RET ))
45-
displayName: 'Build documentation'
46-
47-
- script: |
48-
mkdir -p to_deploy/docs
49-
cp -r web/build/* to_deploy/
50-
cp -r doc/build/html/* to_deploy/docs/
51-
displayName: 'Merge website and docs'
52-
53-
- script: |
54-
cd to_deploy
55-
git init
56-
touch .nojekyll
57-
echo "dev.pandas.io" > CNAME
58-
printf "User-agent: *\nDisallow: /" > robots.txt
59-
git add --all .
60-
git config user.email "[email protected]"
61-
git config user.name "pandas-bot"
62-
git commit -m "pandas web and documentation in master"
63-
displayName: 'Create git repo for docs build'
64-
condition : |
65-
and(not(eq(variables['Build.Reason'], 'PullRequest')),
66-
eq(variables['Build.SourceBranch'], 'refs/heads/master'))
67-
68-
# For `InstallSSHKey@0` to work, next steps are required:
69-
# 1. Generate a pair of private/public keys (i.e. `ssh-keygen -t rsa -b 4096 -C "[email protected]"`)
70-
# 2. Go to "Library > Secure files" in the Azure Pipelines dashboard: https://dev.azure.com/pandas-dev/pandas/_library?itemType=SecureFiles
71-
# 3. Click on "+ Secure file"
72-
# 4. Upload the private key (the name of the file must match with the specified in "sshKeySecureFile" input below, "pandas_docs_key")
73-
# 5. Click on file name after it is created, tick the box "Authorize for use in all pipelines" and save
74-
# 6. The public key specified in "sshPublicKey" is the pair of the uploaded private key, and needs to be set as a deploy key of the repo where the docs will be pushed (with write access): https://github.com/pandas-dev/pandas-dev.github.io/settings/keys
75-
- task: InstallSSHKey@0
76-
inputs:
77-
hostName: 'github.com,192.30.252.128 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=='
78-
sshPublicKey: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDHmz3l/EdqrgNxEUKkwDUuUcLv91unig03pYFGO/DMIgCmPdMG96zAgfnESd837Rm0wSSqylwSzkRJt5MV/TpFlcVifDLDQmUhqCeO8Z6dLl/oe35UKmyYICVwcvQTAaHNnYRpKC5IUlTh0JEtw9fGlnp1Ta7U1ENBLbKdpywczElhZu+hOQ892zqOj3CwA+U2329/d6cd7YnqIKoFN9DWT3kS5K6JE4IoBfQEVekIOs23bKjNLvPoOmi6CroAhu/K8j+NCWQjge5eJf2x/yTnIIP1PlEcXoHIr8io517posIx3TBup+CN8bNS1PpDW3jyD3ttl1uoBudjOQrobNnJeR6Rn67DRkG6IhSwr3BWj8alwUG5mTdZzwV5Pa9KZFdIiqX7NoDGg+itsR39QCn0thK8lGRNSR8KrWC1PSjecwelKBO7uQ7rnk/rkrZdBWR4oEA8YgNH8tirUw5WfOr5a0AIaJicKxGKNdMxZt+zmC+bS7F4YCOGIm9KHa43RrKhoGRhRf9fHHHKUPwFGqtWG4ykcUgoamDOURJyepesBAO3FiRE9rLU6ILbB3yEqqoekborHmAJD5vf7PWItW3Q/YQKuk3kkqRcKnexPyzyyq5lUgTi8CxxZdaASIOu294wjBhhdyHlXEkVTNJ9JKkj/obF+XiIIp0cBDsOXY9hDQ== [email protected]'
79-
sshKeySecureFile: 'pandas_docs_key'
80-
displayName: 'Install GitHub ssh deployment key'
81-
condition : |
82-
and(not(eq(variables['Build.Reason'], 'PullRequest')),
83-
eq(variables['Build.SourceBranch'], 'refs/heads/master'))
84-
85-
- script: |
86-
cd to_deploy
87-
git remote add origin [email protected]:pandas-dev/pandas-dev.github.io.git
88-
git push -f origin master
89-
displayName: 'Publish web and docs to GitHub pages'
90-
condition : |
91-
and(not(eq(variables['Build.Reason'], 'PullRequest')),
92-
eq(variables['Build.SourceBranch'], 'refs/heads/master'))

doc/source/getting_started/10min.rst

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ and labeled columns:
3939
df = pd.DataFrame(np.random.randn(6, 4), index=dates, columns=list('ABCD'))
4040
df
4141
42-
Creating a ``DataFrame`` by passing a dict of objects that can be converted to series-like.
42+
Creating a :class:`DataFrame` by passing a dict of objects that can be converted to series-like.
4343

4444
.. ipython:: python
4545
@@ -51,7 +51,7 @@ Creating a ``DataFrame`` by passing a dict of objects that can be converted to s
5151
'F': 'foo'})
5252
df2
5353
54-
The columns of the resulting ``DataFrame`` have different
54+
The columns of the resulting :class:`DataFrame` have different
5555
:ref:`dtypes <basics.dtypes>`.
5656

5757
.. ipython:: python
@@ -169,7 +169,7 @@ See the indexing documentation :ref:`Indexing and Selecting Data <indexing>` and
169169
Getting
170170
~~~~~~~
171171

172-
Selecting a single column, which yields a ``Series``,
172+
Selecting a single column, which yields a :class:`Series`,
173173
equivalent to ``df.A``:
174174

175175
.. ipython:: python
@@ -469,10 +469,10 @@ Concatenating pandas objects together with :func:`concat`:
469469
pd.concat(pieces)
470470
471471
.. note::
472-
Adding a column to a ``DataFrame`` is relatively fast. However, adding
472+
Adding a column to a :class:`DataFrame` is relatively fast. However, adding
473473
a row requires a copy, and may be expensive. We recommend passing a
474-
pre-built list of records to the ``DataFrame`` constructor instead
475-
of building a ``DataFrame`` by iteratively appending records to it.
474+
pre-built list of records to the :class:`DataFrame` constructor instead
475+
of building a :class:`DataFrame` by iteratively appending records to it.
476476
See :ref:`Appending to dataframe <merging.concatenation>` for more.
477477

478478
Join
@@ -520,15 +520,15 @@ See the :ref:`Grouping section <groupby>`.
520520
'D': np.random.randn(8)})
521521
df
522522
523-
Grouping and then applying the :meth:`~DataFrame.sum` function to the resulting
523+
Grouping and then applying the :meth:`~pandas.core.groupby.GroupBy.sum` function to the resulting
524524
groups.
525525

526526
.. ipython:: python
527527
528528
df.groupby('A').sum()
529529
530530
Grouping by multiple columns forms a hierarchical index, and again we can
531-
apply the ``sum`` function.
531+
apply the :meth:`~pandas.core.groupby.GroupBy.sum` function.
532532

533533
.. ipython:: python
534534
@@ -648,7 +648,7 @@ the quarter end:
648648
Categoricals
649649
------------
650650

651-
pandas can include categorical data in a ``DataFrame``. For full docs, see the
651+
pandas can include categorical data in a :class:`DataFrame`. For full docs, see the
652652
:ref:`categorical introduction <categorical>` and the :ref:`API documentation <api.arrays.categorical>`.
653653

654654
.. ipython:: python
@@ -664,14 +664,13 @@ Convert the raw grades to a categorical data type.
664664
df["grade"]
665665
666666
Rename the categories to more meaningful names (assigning to
667-
``Series.cat.categories`` is inplace!).
667+
:meth:`Series.cat.categories` is inplace!).
668668

669669
.. ipython:: python
670670
671671
df["grade"].cat.categories = ["very good", "good", "very bad"]
672672
673-
Reorder the categories and simultaneously add the missing categories (methods under ``Series
674-
.cat`` return a new ``Series`` by default).
673+
Reorder the categories and simultaneously add the missing categories (methods under :meth:`Series.cat` return a new :class:`Series` by default).
675674

676675
.. ipython:: python
677676

pandas/core/base.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -927,22 +927,50 @@ def max(self, axis=None, skipna=True, *args, **kwargs):
927927

928928
def argmax(self, axis=None, skipna=True, *args, **kwargs):
929929
"""
930-
Return an ndarray of the maximum argument indexer.
930+
Return int position of the largest value in the Series.
931+
932+
If the maximum is achieved in multiple locations,
933+
the first row position is returned.
931934
932935
Parameters
933936
----------
934937
axis : {None}
935938
Dummy argument for consistency with Series.
936939
skipna : bool, default True
940+
Exclude NA/null values when showing the result.
941+
*args, **kwargs
942+
Additional arguments and keywords for compatibility with NumPy.
937943
938944
Returns
939945
-------
940-
numpy.ndarray
941-
Indices of the maximum values.
946+
int
947+
Row position of the maximum values.
942948
943949
See Also
944950
--------
945-
numpy.ndarray.argmax
951+
numpy.ndarray.argmax : Equivalent method for numpy arrays.
952+
Series.argmin : Similar method, but returning the minimum.
953+
Series.idxmax : Return index label of the maximum values.
954+
Series.idxmin : Return index label of the minimum values.
955+
956+
Examples
957+
--------
958+
Consider dataset containing cereal calories
959+
960+
>>> s = pd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0,
961+
... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0})
962+
>>> s
963+
Corn Flakes 100.0
964+
Almond Delight 110.0
965+
Cinnamon Toast Crunch 120.0
966+
Cocoa Puff 110.0
967+
dtype: float64
968+
969+
>>> s.argmax()
970+
2
971+
972+
The maximum cereal calories is in the third element,
973+
since series is zero-indexed.
946974
"""
947975
nv.validate_minmax_axis(axis)
948976
nv.validate_argmax_with_skipna(skipna, args, kwargs)

pandas/core/frame.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8446,9 +8446,8 @@ def isin(self, values) -> "DataFrame":
84468446

84478447
def _from_nested_dict(data):
84488448
# TODO: this should be seriously cythonized
8449-
new_data = {}
8449+
new_data = collections.defaultdict(dict)
84508450
for index, s in data.items():
84518451
for col, v in s.items():
8452-
new_data[col] = new_data.get(col, {})
84538452
new_data[col][index] = v
84548453
return new_data

pandas/core/indexes/base.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -796,20 +796,24 @@ def repeat(self, repeats, axis=None):
796796

797797
def copy(self, name=None, deep=False, dtype=None, names=None):
798798
"""
799-
Make a copy of this object. Name and dtype sets those attributes on
800-
the new object.
799+
Make a copy of this object.
800+
801+
Name and dtype sets those attributes on the new object.
801802
802803
Parameters
803804
----------
804-
name : Label
805+
name : Label, optional
806+
Set name for new object.
805807
deep : bool, default False
806808
dtype : numpy dtype or pandas type, optional
809+
Set dtype for new object.
807810
names : list-like, optional
808811
Kept for compatibility with MultiIndex. Should not be used.
809812
810813
Returns
811814
-------
812815
Index
816+
Index refer to new object which is a copy of this object.
813817
814818
Notes
815819
-----
@@ -3933,18 +3937,35 @@ def memory_usage(self, deep: bool = False) -> int:
39333937

39343938
def where(self, cond, other=None):
39353939
"""
3936-
Return an Index of same shape as self and whose corresponding
3937-
entries are from self where cond is True and otherwise are from
3938-
other.
3940+
Replace values where the condition is False.
3941+
3942+
The replacement is taken from other.
39393943
39403944
Parameters
39413945
----------
39423946
cond : bool array-like with the same length as self
3943-
other : scalar, or array-like
3947+
Condition to select the values on.
3948+
other : scalar, or array-like, default None
3949+
Replacement if the condition is False.
39443950
39453951
Returns
39463952
-------
3947-
Index
3953+
pandas.Index
3954+
A copy of self with values replaced from other
3955+
where the condition is False.
3956+
3957+
See Also
3958+
--------
3959+
Series.where : Same method for Series.
3960+
DataFrame.where : Same method for DataFrame.
3961+
3962+
Examples
3963+
--------
3964+
>>> idx = pd.Index(['car', 'bike', 'train', 'tractor'])
3965+
>>> idx
3966+
Index(['car', 'bike', 'train', 'tractor'], dtype='object')
3967+
>>> idx.where(idx.isin(['car', 'train']), 'other')
3968+
Index(['car', 'other', 'train', 'other'], dtype='object')
39483969
"""
39493970
if other is None:
39503971
other = self._na_value

pandas/core/indexing.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from pandas.util._decorators import Appender
99

1010
from pandas.core.dtypes.common import (
11-
is_float,
1211
is_integer,
1312
is_iterator,
1413
is_list_like,
@@ -1500,18 +1499,10 @@ def _convert_to_indexer(self, key, axis: int, is_setter: bool = False):
15001499
"""
15011500
Much simpler as we only have to deal with our valid types.
15021501
"""
1503-
labels = self.obj._get_axis(axis)
1504-
1505-
# make need to convert a float key
1506-
if isinstance(key, slice):
1507-
labels._validate_positional_slice(key)
1508-
return key
1509-
1510-
elif is_float(key):
1511-
# _validate_indexer call will always raise
1512-
labels._validate_indexer("positional", key, "iloc")
1502+
return key
15131503

1514-
self._validate_key(key, axis)
1504+
def _get_setitem_indexer(self, key):
1505+
# GH#32257 Fall through to let numnpy do validation
15151506
return key
15161507

15171508
# -------------------------------------------------------------------

pandas/tests/frame/indexing/test_indexing.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727

2828
from pandas.tseries.offsets import BDay
2929

30+
# We pass through a TypeError raised by numpy
31+
_slice_msg = "slice indices must be integers or None or have an __index__ method"
32+
3033

3134
class TestGet:
3235
def test_get(self, float_frame):
@@ -994,7 +997,8 @@ def test_getitem_setitem_fancy_exceptions(self, float_frame):
994997
with pytest.raises(IndexingError, match="Too many indexers"):
995998
ix[:, :, :]
996999

997-
with pytest.raises(IndexingError, match="Too many indexers"):
1000+
with pytest.raises(IndexError, match="too many indices for array"):
1001+
# GH#32257 we let numpy do validation, get their exception
9981002
ix[:, :, :] = 1
9991003

10001004
def test_getitem_setitem_boolean_misaligned(self, float_frame):
@@ -1073,7 +1077,7 @@ def test_getitem_setitem_float_labels(self):
10731077

10741078
cp = df.copy()
10751079

1076-
with pytest.raises(TypeError, match=msg):
1080+
with pytest.raises(TypeError, match=_slice_msg):
10771081
cp.iloc[1.0:5] = 0
10781082

10791083
with pytest.raises(TypeError, match=msg):

0 commit comments

Comments
 (0)