From 34783df87f7fc7a3cad255e814f3e4718d3d15af Mon Sep 17 00:00:00 2001 From: Raghav Batra Date: Fri, 11 Aug 2017 00:25:20 +0530 Subject: [PATCH 1/4] Documentation added --- doc/source/style.ipynb | 1185 ---------------------------------------- 1 file changed, 1185 deletions(-) delete mode 100644 doc/source/style.ipynb diff --git a/doc/source/style.ipynb b/doc/source/style.ipynb deleted file mode 100644 index c250787785e14..0000000000000 --- a/doc/source/style.ipynb +++ /dev/null @@ -1,1185 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Styling\n", - "\n", - "*New in version 0.17.1*\n", - "\n", - "*Provisional: This is a new feature and still under development. We'll be adding features and possibly making breaking changes in future releases. We'd love to hear your feedback.*\n", - "\n", - "This document is written as a Jupyter Notebook, and can be viewed or downloaded [here](http://nbviewer.ipython.org/github/pandas-dev/pandas/blob/master/doc/source/style.ipynb).\n", - "\n", - "You can apply **conditional formatting**, the visual styling of a DataFrame\n", - "depending on the data within, by using the ``DataFrame.style`` property.\n", - "This is a property that returns a ``Styler`` object, which has\n", - "useful methods for formatting and displaying DataFrames.\n", - "\n", - "The styling is accomplished using CSS.\n", - "You write \"style functions\" that take scalars, `DataFrame`s or `Series`, and return *like-indexed* DataFrames or Series with CSS `\"attribute: value\"` pairs for the values.\n", - "These functions can be incrementally passed to the `Styler` which collects the styles before rendering." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Building Styles\n", - "\n", - "Pass your style functions into one of the following methods:\n", - "\n", - "- ``Styler.applymap``: elementwise\n", - "- ``Styler.apply``: column-/row-/table-wise\n", - "\n", - "Both of those methods take a function (and some other keyword arguments) and applies your function to the DataFrame in a certain way.\n", - "`Styler.applymap` works through the DataFrame elementwise.\n", - "`Styler.apply` passes each column or row into your DataFrame one-at-a-time or the entire table at once, depending on the `axis` keyword argument.\n", - "For columnwise use `axis=0`, rowwise use `axis=1`, and for the entire table at once use `axis=None`.\n", - "\n", - "For `Styler.applymap` your function should take a scalar and return a single string with the CSS attribute-value pair.\n", - "\n", - "For `Styler.apply` your function should take a Series or DataFrame (depending on the axis parameter), and return a Series or DataFrame with an identical shape where each value is a string with a CSS attribute-value pair.\n", - "\n", - "Let's see some examples." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true, - "nbsphinx": "hidden" - }, - "outputs": [], - "source": [ - "import matplotlib.pyplot\n", - "# We have this here to trigger matplotlib's font cache stuff.\n", - "# This cell is hidden from the output" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "import pandas as pd\n", - "import numpy as np\n", - "\n", - "np.random.seed(24)\n", - "df = pd.DataFrame({'A': np.linspace(1, 10, 10)})\n", - "df = pd.concat([df, pd.DataFrame(np.random.randn(10, 4), columns=list('BCDE'))],\n", - " axis=1)\n", - "df.iloc[0, 2] = np.nan" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here's a boring example of rendering a DataFrame, without any (visible) styles:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df.style" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "*Note*: The `DataFrame.style` attribute is a property that returns a `Styler` object. `Styler` has a `_repr_html_` method defined on it so they are rendered automatically. If you want the actual HTML back for further processing or for writing to file call the `.render()` method which returns a string.\n", - "\n", - "The above output looks very similar to the standard DataFrame HTML representation. But we've done some work behind the scenes to attach CSS classes to each cell. We can view these by calling the `.render` method." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df.style.highlight_null().render().split('\\n')[:10]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The `row0_col2` is the identifier for that particular cell. We've also prepended each row/column identifier with a UUID unique to each DataFrame so that the style from one doesn't collide with the styling from another within the same notebook or page (you can set the `uuid` if you'd like to tie together the styling of two DataFrames).\n", - "\n", - "When writing style functions, you take care of producing the CSS attribute / value pairs you want. Pandas matches those up with the CSS classes that identify each cell." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Let's write a simple style function that will color negative numbers red and positive numbers black." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def color_negative_red(val):\n", - " \"\"\"\n", - " Takes a scalar and returns a string with\n", - " the css property `'color: red'` for negative\n", - " strings, black otherwise.\n", - " \"\"\"\n", - " color = 'red' if val < 0 else 'black'\n", - " return 'color: %s' % color" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In this case, the cell's style depends only on it's own value.\n", - "That means we should use the `Styler.applymap` method which works elementwise." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "s = df.style.applymap(color_negative_red)\n", - "s" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Notice the similarity with the standard `df.applymap`, which operates on DataFrames elementwise. We want you to be able to resuse your existing knowledge of how to interact with DataFrames.\n", - "\n", - "Notice also that our function returned a string containing the CSS attribute and value, separated by a colon just like in a `'.format(css))" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.1" - } - }, - "nbformat": 4, - "nbformat_minor": 1 -} From 2b8c5ea88678e1275d0e77fce8331588fb078b56 Mon Sep 17 00:00:00 2001 From: Raghav Batra Date: Fri, 11 Aug 2017 16:47:29 +0530 Subject: [PATCH 2/4] DOC: Updated pd.Series.replace Updated documentation so that it matched the functionality of pd.Series.replace and NOT pd.DataFrame.replace Fixes #13852 --- doc/source/style.ipynb | 1185 ---------------------------------------- pandas/core/generic.py | 26 +- 2 files changed, 10 insertions(+), 1201 deletions(-) delete mode 100644 doc/source/style.ipynb diff --git a/doc/source/style.ipynb b/doc/source/style.ipynb deleted file mode 100644 index c250787785e14..0000000000000 --- a/doc/source/style.ipynb +++ /dev/null @@ -1,1185 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Styling\n", - "\n", - "*New in version 0.17.1*\n", - "\n", - "*Provisional: This is a new feature and still under development. We'll be adding features and possibly making breaking changes in future releases. We'd love to hear your feedback.*\n", - "\n", - "This document is written as a Jupyter Notebook, and can be viewed or downloaded [here](http://nbviewer.ipython.org/github/pandas-dev/pandas/blob/master/doc/source/style.ipynb).\n", - "\n", - "You can apply **conditional formatting**, the visual styling of a DataFrame\n", - "depending on the data within, by using the ``DataFrame.style`` property.\n", - "This is a property that returns a ``Styler`` object, which has\n", - "useful methods for formatting and displaying DataFrames.\n", - "\n", - "The styling is accomplished using CSS.\n", - "You write \"style functions\" that take scalars, `DataFrame`s or `Series`, and return *like-indexed* DataFrames or Series with CSS `\"attribute: value\"` pairs for the values.\n", - "These functions can be incrementally passed to the `Styler` which collects the styles before rendering." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Building Styles\n", - "\n", - "Pass your style functions into one of the following methods:\n", - "\n", - "- ``Styler.applymap``: elementwise\n", - "- ``Styler.apply``: column-/row-/table-wise\n", - "\n", - "Both of those methods take a function (and some other keyword arguments) and applies your function to the DataFrame in a certain way.\n", - "`Styler.applymap` works through the DataFrame elementwise.\n", - "`Styler.apply` passes each column or row into your DataFrame one-at-a-time or the entire table at once, depending on the `axis` keyword argument.\n", - "For columnwise use `axis=0`, rowwise use `axis=1`, and for the entire table at once use `axis=None`.\n", - "\n", - "For `Styler.applymap` your function should take a scalar and return a single string with the CSS attribute-value pair.\n", - "\n", - "For `Styler.apply` your function should take a Series or DataFrame (depending on the axis parameter), and return a Series or DataFrame with an identical shape where each value is a string with a CSS attribute-value pair.\n", - "\n", - "Let's see some examples." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true, - "nbsphinx": "hidden" - }, - "outputs": [], - "source": [ - "import matplotlib.pyplot\n", - "# We have this here to trigger matplotlib's font cache stuff.\n", - "# This cell is hidden from the output" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "import pandas as pd\n", - "import numpy as np\n", - "\n", - "np.random.seed(24)\n", - "df = pd.DataFrame({'A': np.linspace(1, 10, 10)})\n", - "df = pd.concat([df, pd.DataFrame(np.random.randn(10, 4), columns=list('BCDE'))],\n", - " axis=1)\n", - "df.iloc[0, 2] = np.nan" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here's a boring example of rendering a DataFrame, without any (visible) styles:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df.style" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "*Note*: The `DataFrame.style` attribute is a property that returns a `Styler` object. `Styler` has a `_repr_html_` method defined on it so they are rendered automatically. If you want the actual HTML back for further processing or for writing to file call the `.render()` method which returns a string.\n", - "\n", - "The above output looks very similar to the standard DataFrame HTML representation. But we've done some work behind the scenes to attach CSS classes to each cell. We can view these by calling the `.render` method." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df.style.highlight_null().render().split('\\n')[:10]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The `row0_col2` is the identifier for that particular cell. We've also prepended each row/column identifier with a UUID unique to each DataFrame so that the style from one doesn't collide with the styling from another within the same notebook or page (you can set the `uuid` if you'd like to tie together the styling of two DataFrames).\n", - "\n", - "When writing style functions, you take care of producing the CSS attribute / value pairs you want. Pandas matches those up with the CSS classes that identify each cell." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Let's write a simple style function that will color negative numbers red and positive numbers black." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def color_negative_red(val):\n", - " \"\"\"\n", - " Takes a scalar and returns a string with\n", - " the css property `'color: red'` for negative\n", - " strings, black otherwise.\n", - " \"\"\"\n", - " color = 'red' if val < 0 else 'black'\n", - " return 'color: %s' % color" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In this case, the cell's style depends only on it's own value.\n", - "That means we should use the `Styler.applymap` method which works elementwise." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "s = df.style.applymap(color_negative_red)\n", - "s" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Notice the similarity with the standard `df.applymap`, which operates on DataFrames elementwise. We want you to be able to resuse your existing knowledge of how to interact with DataFrames.\n", - "\n", - "Notice also that our function returned a string containing the CSS attribute and value, separated by a colon just like in a `'.format(css))" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.1" - } - }, - "nbformat": 4, - "nbformat_minor": 1 -} diff --git a/pandas/core/generic.py b/pandas/core/generic.py index bd3297f66a469..618bbf873d312 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -4108,11 +4108,9 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None, * dict: - - Nested dictionaries, e.g., {'a': {'b': nan}}, are read as - follows: look in column 'a' for the value 'b' and replace it - with nan. You can nest regular expressions as well. Note that - column names (the top-level dictionary keys in a nested - dictionary) **cannot** be regular expressions. + - Dictionaries, e.g., {'a': 'b'}, are read as + follows: look for the value 'a' and replace it + with 'b'. - Keys map to column names and values map to substitution values. You can treat this as a special case of passing two lists except that you are specifying the column to search in. @@ -4126,14 +4124,10 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None, See the examples section for examples of each of these. value : scalar, dict, list, str, regex, default None - Value to use to fill holes (e.g. 0), alternately a dict of values - specifying which value to use for each column (columns not in the - dict will not be filled). Regular expressions, strings and lists or - dicts of such objects are also allowed. + Value to use to fill holes (e.g. 0). Regular expressions, strings + and lists or dicts of such objects are also allowed. inplace : boolean, default False - If True, in place. Note: this will modify any - other views on this object (e.g. a column form a DataFrame). - Returns the caller if this is True. + If True, in place. Returns the caller if this is True. limit : int, default None Maximum size gap to forward or backward fill regex : bool or same types as `to_replace`, default False @@ -4148,13 +4142,13 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None, See Also -------- - NDFrame.reindex - NDFrame.asfreq - NDFrame.fillna + Series.reindex + Series.asfreq + Series.fillna Returns ------- - filled : NDFrame + filled : Series Raises ------ From 104b95167c207edc8c8f3ca114c6906ed9bf63cb Mon Sep 17 00:00:00 2001 From: Raghav Batra Date: Fri, 11 Aug 2017 17:02:30 +0530 Subject: [PATCH 3/4] DOC: Removed trailing whitespace --- pandas/core/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 618bbf873d312..ff6937be7a411 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -4124,7 +4124,7 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None, See the examples section for examples of each of these. value : scalar, dict, list, str, regex, default None - Value to use to fill holes (e.g. 0). Regular expressions, strings + Value to use to fill holes (e.g. 0). Regular expressions, strings and lists or dicts of such objects are also allowed. inplace : boolean, default False If True, in place. Returns the caller if this is True. From b92e3e9da077ea217c915409585303bf0487908d Mon Sep 17 00:00:00 2001 From: Raghav Batra Date: Fri, 11 Aug 2017 18:10:25 +0530 Subject: [PATCH 4/4] Blah --- doc/source/style.ipynb | 1185 ++++++++++++++++++++++++++++++++++++++++ pandas/core/generic.py | 27 +- 2 files changed, 1204 insertions(+), 8 deletions(-) create mode 100644 doc/source/style.ipynb diff --git a/doc/source/style.ipynb b/doc/source/style.ipynb new file mode 100644 index 0000000000000..c250787785e14 --- /dev/null +++ b/doc/source/style.ipynb @@ -0,0 +1,1185 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# Styling\n", + "\n", + "*New in version 0.17.1*\n", + "\n", + "*Provisional: This is a new feature and still under development. We'll be adding features and possibly making breaking changes in future releases. We'd love to hear your feedback.*\n", + "\n", + "This document is written as a Jupyter Notebook, and can be viewed or downloaded [here](http://nbviewer.ipython.org/github/pandas-dev/pandas/blob/master/doc/source/style.ipynb).\n", + "\n", + "You can apply **conditional formatting**, the visual styling of a DataFrame\n", + "depending on the data within, by using the ``DataFrame.style`` property.\n", + "This is a property that returns a ``Styler`` object, which has\n", + "useful methods for formatting and displaying DataFrames.\n", + "\n", + "The styling is accomplished using CSS.\n", + "You write \"style functions\" that take scalars, `DataFrame`s or `Series`, and return *like-indexed* DataFrames or Series with CSS `\"attribute: value\"` pairs for the values.\n", + "These functions can be incrementally passed to the `Styler` which collects the styles before rendering." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Building Styles\n", + "\n", + "Pass your style functions into one of the following methods:\n", + "\n", + "- ``Styler.applymap``: elementwise\n", + "- ``Styler.apply``: column-/row-/table-wise\n", + "\n", + "Both of those methods take a function (and some other keyword arguments) and applies your function to the DataFrame in a certain way.\n", + "`Styler.applymap` works through the DataFrame elementwise.\n", + "`Styler.apply` passes each column or row into your DataFrame one-at-a-time or the entire table at once, depending on the `axis` keyword argument.\n", + "For columnwise use `axis=0`, rowwise use `axis=1`, and for the entire table at once use `axis=None`.\n", + "\n", + "For `Styler.applymap` your function should take a scalar and return a single string with the CSS attribute-value pair.\n", + "\n", + "For `Styler.apply` your function should take a Series or DataFrame (depending on the axis parameter), and return a Series or DataFrame with an identical shape where each value is a string with a CSS attribute-value pair.\n", + "\n", + "Let's see some examples." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true, + "nbsphinx": "hidden" + }, + "outputs": [], + "source": [ + "import matplotlib.pyplot\n", + "# We have this here to trigger matplotlib's font cache stuff.\n", + "# This cell is hidden from the output" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "import pandas as pd\n", + "import numpy as np\n", + "\n", + "np.random.seed(24)\n", + "df = pd.DataFrame({'A': np.linspace(1, 10, 10)})\n", + "df = pd.concat([df, pd.DataFrame(np.random.randn(10, 4), columns=list('BCDE'))],\n", + " axis=1)\n", + "df.iloc[0, 2] = np.nan" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Here's a boring example of rendering a DataFrame, without any (visible) styles:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "df.style" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "*Note*: The `DataFrame.style` attribute is a property that returns a `Styler` object. `Styler` has a `_repr_html_` method defined on it so they are rendered automatically. If you want the actual HTML back for further processing or for writing to file call the `.render()` method which returns a string.\n", + "\n", + "The above output looks very similar to the standard DataFrame HTML representation. But we've done some work behind the scenes to attach CSS classes to each cell. We can view these by calling the `.render` method." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "df.style.highlight_null().render().split('\\n')[:10]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The `row0_col2` is the identifier for that particular cell. We've also prepended each row/column identifier with a UUID unique to each DataFrame so that the style from one doesn't collide with the styling from another within the same notebook or page (you can set the `uuid` if you'd like to tie together the styling of two DataFrames).\n", + "\n", + "When writing style functions, you take care of producing the CSS attribute / value pairs you want. Pandas matches those up with the CSS classes that identify each cell." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's write a simple style function that will color negative numbers red and positive numbers black." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def color_negative_red(val):\n", + " \"\"\"\n", + " Takes a scalar and returns a string with\n", + " the css property `'color: red'` for negative\n", + " strings, black otherwise.\n", + " \"\"\"\n", + " color = 'red' if val < 0 else 'black'\n", + " return 'color: %s' % color" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In this case, the cell's style depends only on it's own value.\n", + "That means we should use the `Styler.applymap` method which works elementwise." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "s = df.style.applymap(color_negative_red)\n", + "s" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Notice the similarity with the standard `df.applymap`, which operates on DataFrames elementwise. We want you to be able to resuse your existing knowledge of how to interact with DataFrames.\n", + "\n", + "Notice also that our function returned a string containing the CSS attribute and value, separated by a colon just like in a `'.format(css))" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.1" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/pandas/core/generic.py b/pandas/core/generic.py index ff6937be7a411..f6094532c4eb2 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -4108,9 +4108,11 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None, * dict: - - Dictionaries, e.g., {'a': 'b'}, are read as - follows: look for the value 'a' and replace it - with 'b'. + - Nested dictionaries, e.g., {'a': {'b': nan}}, are read as + follows: look in column 'a' for the value 'b' and replace it + with nan. You can nest regular expressions as well. Note that + column names (the top-level dictionary keys in a nested + dictionary) **cannot** be regular expressions. - Keys map to column names and values map to substitution values. You can treat this as a special case of passing two lists except that you are specifying the column to search in. @@ -4124,10 +4126,19 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None, See the examples section for examples of each of these. value : scalar, dict, list, str, regex, default None +<<<<<<< HEAD Value to use to fill holes (e.g. 0). Regular expressions, strings and lists or dicts of such objects are also allowed. +======= + Value to use to fill holes (e.g. 0), alternately a dict of values + specifying which value to use for each column (columns not in the + dict will not be filled). Regular expressions, strings and lists or + dicts of such objects are also allowed. +>>>>>>> parent of 2b8c5ea88... DOC: Updated pd.Series.replace inplace : boolean, default False - If True, in place. Returns the caller if this is True. + If True, in place. Note: this will modify any + other views on this object (e.g. a column form a DataFrame). + Returns the caller if this is True. limit : int, default None Maximum size gap to forward or backward fill regex : bool or same types as `to_replace`, default False @@ -4142,13 +4153,13 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None, See Also -------- - Series.reindex - Series.asfreq - Series.fillna + NDFrame.reindex + NDFrame.asfreq + NDFrame.fillna Returns ------- - filled : Series + filled : NDFrame Raises ------