Skip to content

Sync Fork from Upstream Repo #66

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 16 commits into from
Feb 27, 2020
Merged
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
35 changes: 34 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,39 @@ jobs:
echo "region = BHS" >> $RCLONE_CONFIG_PATH
if: github.event_name == 'push'

- name: Sync web
- name: Sync web with OVH
run: rclone sync pandas_web ovh_cloud_pandas_web:dev
if: github.event_name == 'push'

- name: Create git repo to upload the built docs to GitHub pages
run: |
cd pandas_web
git init
touch .nojekyll
echo "dev.pandas.io" > CNAME
printf "User-agent: *\nDisallow: /" > robots.txt
git add --all .
git config user.email "[email protected]"
git config user.name "pandas-bot"
git commit -m "pandas web and documentation in master"
if: github.event_name == 'push'

# For this task to work, next steps are required:
# 1. Generate a pair of private/public keys (i.e. `ssh-keygen -t rsa -b 4096 -C "[email protected]"`)
# 2. Go to https://github.com/pandas-dev/pandas/settings/secrets
# 3. Click on "Add a new secret"
# 4. Name: "github_pagas_ssh_key", Value: <Content of the private ssh key>
# 5. The public key needs to be upladed to https://github.com/pandas-dev/pandas-dev.github.io/settings/keys
- name: Install GitHub pages ssh deployment key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.github_pages_ssh_key }}
known_hosts: 'github.com,192.30.252.128 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=='
if: github.event_name == 'push'

- name: Publish web and docs to GitHub pages
run: |
cd pandas_web
git remote add origin [email protected]:pandas-dev/pandas-dev.github.io.git
git push -f origin master || true
if: github.event_name == 'push'
75 changes: 0 additions & 75 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,78 +15,3 @@ jobs:
parameters:
name: Windows
vmImage: vs2017-win2016

- job: 'Web_and_Docs'
pool:
vmImage: ubuntu-16.04
timeoutInMinutes: 90
steps:
- script: |
echo '##vso[task.setvariable variable=ENV_FILE]environment.yml'
echo '##vso[task.prependpath]$(HOME)/miniconda3/bin'
displayName: 'Setting environment variables'

- script: |
sudo apt-get install -y libc6-dev-i386
ci/setup_env.sh
displayName: 'Setup environment and build pandas'

- script: |
source activate pandas-dev
python web/pandas_web.py web/pandas --target-path=web/build
displayName: 'Build website'

- script: |
source activate pandas-dev
# 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)
doc/make.py --warnings-are-errors | tee sphinx.log ; SPHINX_RET=${PIPESTATUS[0]}
grep -B1 "^<<<-------------------------------------------------------------------------$" sphinx.log ; IPY_RET=$(( $? != 1 ))
exit $(( $SPHINX_RET + $IPY_RET ))
displayName: 'Build documentation'

- script: |
mkdir -p to_deploy/docs
cp -r web/build/* to_deploy/
cp -r doc/build/html/* to_deploy/docs/
displayName: 'Merge website and docs'

- script: |
cd to_deploy
git init
touch .nojekyll
echo "dev.pandas.io" > CNAME
printf "User-agent: *\nDisallow: /" > robots.txt
git add --all .
git config user.email "[email protected]"
git config user.name "pandas-bot"
git commit -m "pandas web and documentation in master"
displayName: 'Create git repo for docs build'
condition : |
and(not(eq(variables['Build.Reason'], 'PullRequest')),
eq(variables['Build.SourceBranch'], 'refs/heads/master'))

# For `InstallSSHKey@0` to work, next steps are required:
# 1. Generate a pair of private/public keys (i.e. `ssh-keygen -t rsa -b 4096 -C "[email protected]"`)
# 2. Go to "Library > Secure files" in the Azure Pipelines dashboard: https://dev.azure.com/pandas-dev/pandas/_library?itemType=SecureFiles
# 3. Click on "+ Secure file"
# 4. Upload the private key (the name of the file must match with the specified in "sshKeySecureFile" input below, "pandas_docs_key")
# 5. Click on file name after it is created, tick the box "Authorize for use in all pipelines" and save
# 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
- task: InstallSSHKey@0
inputs:
hostName: 'github.com,192.30.252.128 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=='
sshPublicKey: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDHmz3l/EdqrgNxEUKkwDUuUcLv91unig03pYFGO/DMIgCmPdMG96zAgfnESd837Rm0wSSqylwSzkRJt5MV/TpFlcVifDLDQmUhqCeO8Z6dLl/oe35UKmyYICVwcvQTAaHNnYRpKC5IUlTh0JEtw9fGlnp1Ta7U1ENBLbKdpywczElhZu+hOQ892zqOj3CwA+U2329/d6cd7YnqIKoFN9DWT3kS5K6JE4IoBfQEVekIOs23bKjNLvPoOmi6CroAhu/K8j+NCWQjge5eJf2x/yTnIIP1PlEcXoHIr8io517posIx3TBup+CN8bNS1PpDW3jyD3ttl1uoBudjOQrobNnJeR6Rn67DRkG6IhSwr3BWj8alwUG5mTdZzwV5Pa9KZFdIiqX7NoDGg+itsR39QCn0thK8lGRNSR8KrWC1PSjecwelKBO7uQ7rnk/rkrZdBWR4oEA8YgNH8tirUw5WfOr5a0AIaJicKxGKNdMxZt+zmC+bS7F4YCOGIm9KHa43RrKhoGRhRf9fHHHKUPwFGqtWG4ykcUgoamDOURJyepesBAO3FiRE9rLU6ILbB3yEqqoekborHmAJD5vf7PWItW3Q/YQKuk3kkqRcKnexPyzyyq5lUgTi8CxxZdaASIOu294wjBhhdyHlXEkVTNJ9JKkj/obF+XiIIp0cBDsOXY9hDQ== [email protected]'
sshKeySecureFile: 'pandas_docs_key'
displayName: 'Install GitHub ssh deployment key'
condition : |
and(not(eq(variables['Build.Reason'], 'PullRequest')),
eq(variables['Build.SourceBranch'], 'refs/heads/master'))

- script: |
cd to_deploy
git remote add origin [email protected]:pandas-dev/pandas-dev.github.io.git
git push -f origin master
displayName: 'Publish web and docs to GitHub pages'
condition : |
and(not(eq(variables['Build.Reason'], 'PullRequest')),
eq(variables['Build.SourceBranch'], 'refs/heads/master'))
23 changes: 11 additions & 12 deletions doc/source/getting_started/10min.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ and labeled columns:
df = pd.DataFrame(np.random.randn(6, 4), index=dates, columns=list('ABCD'))
df

Creating a ``DataFrame`` by passing a dict of objects that can be converted to series-like.
Creating a :class:`DataFrame` by passing a dict of objects that can be converted to series-like.

.. ipython:: python

Expand All @@ -51,7 +51,7 @@ Creating a ``DataFrame`` by passing a dict of objects that can be converted to s
'F': 'foo'})
df2

The columns of the resulting ``DataFrame`` have different
The columns of the resulting :class:`DataFrame` have different
:ref:`dtypes <basics.dtypes>`.

.. ipython:: python
Expand Down Expand Up @@ -169,7 +169,7 @@ See the indexing documentation :ref:`Indexing and Selecting Data <indexing>` and
Getting
~~~~~~~

Selecting a single column, which yields a ``Series``,
Selecting a single column, which yields a :class:`Series`,
equivalent to ``df.A``:

.. ipython:: python
Expand Down Expand Up @@ -469,10 +469,10 @@ Concatenating pandas objects together with :func:`concat`:
pd.concat(pieces)

.. note::
Adding a column to a ``DataFrame`` is relatively fast. However, adding
Adding a column to a :class:`DataFrame` is relatively fast. However, adding
a row requires a copy, and may be expensive. We recommend passing a
pre-built list of records to the ``DataFrame`` constructor instead
of building a ``DataFrame`` by iteratively appending records to it.
pre-built list of records to the :class:`DataFrame` constructor instead
of building a :class:`DataFrame` by iteratively appending records to it.
See :ref:`Appending to dataframe <merging.concatenation>` for more.

Join
Expand Down Expand Up @@ -520,15 +520,15 @@ See the :ref:`Grouping section <groupby>`.
'D': np.random.randn(8)})
df

Grouping and then applying the :meth:`~DataFrame.sum` function to the resulting
Grouping and then applying the :meth:`~pandas.core.groupby.GroupBy.sum` function to the resulting
groups.

.. ipython:: python

df.groupby('A').sum()

Grouping by multiple columns forms a hierarchical index, and again we can
apply the ``sum`` function.
apply the :meth:`~pandas.core.groupby.GroupBy.sum` function.

.. ipython:: python

Expand Down Expand Up @@ -648,7 +648,7 @@ the quarter end:
Categoricals
------------

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

.. ipython:: python
Expand All @@ -664,14 +664,13 @@ Convert the raw grades to a categorical data type.
df["grade"]

Rename the categories to more meaningful names (assigning to
``Series.cat.categories`` is inplace!).
:meth:`Series.cat.categories` is inplace!).

.. ipython:: python

df["grade"].cat.categories = ["very good", "good", "very bad"]

Reorder the categories and simultaneously add the missing categories (methods under ``Series
.cat`` return a new ``Series`` by default).
Reorder the categories and simultaneously add the missing categories (methods under :meth:`Series.cat` return a new :class:`Series` by default).

.. ipython:: python

Expand Down
36 changes: 32 additions & 4 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,22 +927,50 @@ def max(self, axis=None, skipna=True, *args, **kwargs):

def argmax(self, axis=None, skipna=True, *args, **kwargs):
"""
Return an ndarray of the maximum argument indexer.
Return int position of the largest value in the Series.

If the maximum is achieved in multiple locations,
the first row position is returned.

Parameters
----------
axis : {None}
Dummy argument for consistency with Series.
skipna : bool, default True
Exclude NA/null values when showing the result.
*args, **kwargs
Additional arguments and keywords for compatibility with NumPy.

Returns
-------
numpy.ndarray
Indices of the maximum values.
int
Row position of the maximum values.

See Also
--------
numpy.ndarray.argmax
numpy.ndarray.argmax : Equivalent method for numpy arrays.
Series.argmin : Similar method, but returning the minimum.
Series.idxmax : Return index label of the maximum values.
Series.idxmin : Return index label of the minimum values.

Examples
--------
Consider dataset containing cereal calories

>>> s = pd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0,
... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0})
>>> s
Corn Flakes 100.0
Almond Delight 110.0
Cinnamon Toast Crunch 120.0
Cocoa Puff 110.0
dtype: float64

>>> s.argmax()
2

The maximum cereal calories is in the third element,
since series is zero-indexed.
"""
nv.validate_minmax_axis(axis)
nv.validate_argmax_with_skipna(skipna, args, kwargs)
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -8446,9 +8446,8 @@ def isin(self, values) -> "DataFrame":

def _from_nested_dict(data):
# TODO: this should be seriously cythonized
new_data = {}
new_data = collections.defaultdict(dict)
for index, s in data.items():
for col, v in s.items():
new_data[col] = new_data.get(col, {})
new_data[col][index] = v
return new_data
37 changes: 29 additions & 8 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,20 +796,24 @@ def repeat(self, repeats, axis=None):

def copy(self, name=None, deep=False, dtype=None, names=None):
"""
Make a copy of this object. Name and dtype sets those attributes on
the new object.
Make a copy of this object.

Name and dtype sets those attributes on the new object.

Parameters
----------
name : Label
name : Label, optional
Set name for new object.
deep : bool, default False
dtype : numpy dtype or pandas type, optional
Set dtype for new object.
names : list-like, optional
Kept for compatibility with MultiIndex. Should not be used.

Returns
-------
Index
Index refer to new object which is a copy of this object.

Notes
-----
Expand Down Expand Up @@ -3933,18 +3937,35 @@ def memory_usage(self, deep: bool = False) -> int:

def where(self, cond, other=None):
"""
Return an Index of same shape as self and whose corresponding
entries are from self where cond is True and otherwise are from
other.
Replace values where the condition is False.

The replacement is taken from other.

Parameters
----------
cond : bool array-like with the same length as self
other : scalar, or array-like
Condition to select the values on.
other : scalar, or array-like, default None
Replacement if the condition is False.

Returns
-------
Index
pandas.Index
A copy of self with values replaced from other
where the condition is False.

See Also
--------
Series.where : Same method for Series.
DataFrame.where : Same method for DataFrame.

Examples
--------
>>> idx = pd.Index(['car', 'bike', 'train', 'tractor'])
>>> idx
Index(['car', 'bike', 'train', 'tractor'], dtype='object')
>>> idx.where(idx.isin(['car', 'train']), 'other')
Index(['car', 'other', 'train', 'other'], dtype='object')
"""
if other is None:
other = self._na_value
Expand Down
15 changes: 3 additions & 12 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from pandas.util._decorators import Appender

from pandas.core.dtypes.common import (
is_float,
is_integer,
is_iterator,
is_list_like,
Expand Down Expand Up @@ -1500,18 +1499,10 @@ def _convert_to_indexer(self, key, axis: int, is_setter: bool = False):
"""
Much simpler as we only have to deal with our valid types.
"""
labels = self.obj._get_axis(axis)

# make need to convert a float key
if isinstance(key, slice):
labels._validate_positional_slice(key)
return key

elif is_float(key):
# _validate_indexer call will always raise
labels._validate_indexer("positional", key, "iloc")
return key

self._validate_key(key, axis)
def _get_setitem_indexer(self, key):
# GH#32257 Fall through to let numnpy do validation
return key

# -------------------------------------------------------------------
Expand Down
8 changes: 6 additions & 2 deletions pandas/tests/frame/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

from pandas.tseries.offsets import BDay

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


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

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

def test_getitem_setitem_boolean_misaligned(self, float_frame):
Expand Down Expand Up @@ -1073,7 +1077,7 @@ def test_getitem_setitem_float_labels(self):

cp = df.copy()

with pytest.raises(TypeError, match=msg):
with pytest.raises(TypeError, match=_slice_msg):
cp.iloc[1.0:5] = 0

with pytest.raises(TypeError, match=msg):
Expand Down
Loading