From ccd4f2161fb40a9f5850750721292155fadbdd48 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Sat, 13 Jun 2015 15:38:06 +0200 Subject: [PATCH] DOC: fix docstrings --- doc/source/release.rst | 5 ++++ doc/source/whatsnew/v0.16.2.txt | 1 - pandas/core/generic.py | 2 +- pandas/io/json.py | 53 ++++++++++++++++++--------------- 4 files changed, 35 insertions(+), 26 deletions(-) diff --git a/doc/source/release.rst b/doc/source/release.rst index 7e7479b2c464c..399286e6dc58b 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -53,6 +53,11 @@ pandas 0.16.2 This is a minor release from 0.16.1 and includes a large number of bug fixes along with several new features, enhancements, and performance improvements. +Highlights include: + +- A new ``pipe`` method, see :ref:`here ` +- Documentation on how to use `numba `_ with *pandas*, see :ref:`here ` + See the :ref:`v0.16.2 Whatsnew ` overview for an extensive list of all enhancements and bugs that have been fixed in 0.16.2. diff --git a/doc/source/whatsnew/v0.16.2.txt b/doc/source/whatsnew/v0.16.2.txt index 8408412d66271..bfe44290e49d2 100644 --- a/doc/source/whatsnew/v0.16.2.txt +++ b/doc/source/whatsnew/v0.16.2.txt @@ -13,7 +13,6 @@ Highlights include: - A new ``pipe`` method, see :ref:`here ` - Documentation on how to use numba_ with *pandas*, see :ref:`here ` -Check the :ref:`API Changes ` before updating. .. contents:: What's new in v0.16.2 :local: diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 112ace3df08e2..35db4051c60c8 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -2050,7 +2050,7 @@ def sample(self, n=None, frac=None, replace=False, weights=None, random_state=No return self.take(locs, axis=axis) _shared_docs['pipe'] = (""" - Apply func(self, *args, **kwargs) + Apply func(self, \*args, \*\*kwargs) .. versionadded:: 0.16.2 diff --git a/pandas/io/json.py b/pandas/io/json.py index 0659e34c3f27b..2c1333326b701 100644 --- a/pandas/io/json.py +++ b/pandas/io/json.py @@ -640,34 +640,39 @@ def json_normalize(data, record_path=None, meta=None, path to records is ['foo', 'bar'] meta_prefix : string, default None + Returns + ------- + frame : DataFrame + Examples -------- - data = [{'state': 'Florida', - 'shortname': 'FL', - 'info': { - 'governor': 'Rick Scott' - }, - 'counties': [{'name': 'Dade', 'population': 12345}, - {'name': 'Broward', 'population': 40000}, - {'name': 'Palm Beach', 'population': 60000}]}, - {'state': 'Ohio', - 'shortname': 'OH', - 'info': { - 'governor': 'John Kasich' - }, - 'counties': [{'name': 'Summit', 'population': 1234}, - {'name': 'Cuyahoga', 'population': 1337}]}] - - result = json_normalize(data, 'counties', ['state', 'shortname', - ['info', 'governor']]) - - state governor - Florida Rick Scott + >>> data = [{'state': 'Florida', + ... 'shortname': 'FL', + ... 'info': { + ... 'governor': 'Rick Scott' + ... }, + ... 'counties': [{'name': 'Dade', 'population': 12345}, + ... {'name': 'Broward', 'population': 40000}, + ... {'name': 'Palm Beach', 'population': 60000}]}, + ... {'state': 'Ohio', + ... 'shortname': 'OH', + ... 'info': { + ... 'governor': 'John Kasich' + ... }, + ... 'counties': [{'name': 'Summit', 'population': 1234}, + ... {'name': 'Cuyahoga', 'population': 1337}]}] + >>> from pandas.io.json import json_normalize + >>> result = json_normalize(data, 'counties', ['state', 'shortname', + ... ['info', 'governor']]) + >>> result + name population info.governor state shortname + 0 Dade 12345 Rick Scott Florida FL + 1 Broward 40000 Rick Scott Florida FL + 2 Palm Beach 60000 Rick Scott Florida FL + 3 Summit 1234 John Kasich Ohio OH + 4 Cuyahoga 1337 John Kasich Ohio OH - Returns - ------- - frame : DataFrame """ def _pull_field(js, spec): result = js