Skip to content

Changed import statements in examples in DOCs #21774

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 2 commits into from
Jul 7, 2018
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
1 change: 0 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -5643,7 +5643,6 @@ def unstack(self, level=-1, fill_value=None):

Examples
--------
>>> import pandas as pd
>>> df = pd.DataFrame({'A': {0: 'a', 1: 'b', 2: 'c'},
... 'B': {0: 1, 1: 3, 2: 5},
... 'C': {0: 2, 1: 4, 2: 6}})
Expand Down
1 change: 0 additions & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4824,7 +4824,6 @@ def ftypes(self):

Examples
--------
>>> import numpy as np
>>> arr = np.random.RandomState(0).randn(100, 4)
>>> arr[arr < .8] = np.nan
>>> pd.DataFrame(arr).ftypes
Expand Down
2 changes: 0 additions & 2 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -3704,7 +3704,6 @@ def filter(self, func, dropna=True, *args, **kwargs): # noqa

Examples
--------
>>> import pandas as pd
>>> df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar',
... 'foo', 'bar'],
... 'B' : [1, 2, 3, 4, 5, 6],
Expand Down Expand Up @@ -4538,7 +4537,6 @@ def filter(self, func, dropna=True, *args, **kwargs): # noqa

Examples
--------
>>> import pandas as pd
>>> df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar',
... 'foo', 'bar'],
... 'B' : [1, 2, 3, 4, 5, 6],
Expand Down
1 change: 0 additions & 1 deletion pandas/core/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def panel_index(time, panels, names=None):

or

>>> import numpy as np
>>> years = np.repeat(range(1960,1963), 3)
>>> panels = np.tile(['A', 'B', 'C'], 3)
>>> panel_idx = panel_index(years, panels)
Expand Down
3 changes: 0 additions & 3 deletions pandas/core/reshape/melt.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def lreshape(data, groups, dropna=True, label=None):

Examples
--------
>>> import pandas as pd
>>> data = pd.DataFrame({'hr1': [514, 573], 'hr2': [545, 526],
... 'team': ['Red Sox', 'Yankees'],
... 'year1': [2007, 2007], 'year2': [2008, 2008]})
Expand Down Expand Up @@ -217,8 +216,6 @@ def wide_to_long(df, stubnames, i, j, sep="", suffix=r'\d+'):

Examples
--------
>>> import pandas as pd
>>> import numpy as np
>>> np.random.seed(123)
>>> df = pd.DataFrame({"A1970" : {0 : "a", 1 : "b", 2 : "c"},
... "A1980" : {0 : "d", 1 : "e", 2 : "f"},
Expand Down
2 changes: 0 additions & 2 deletions pandas/core/reshape/reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class _Unstacker(object):

Examples
--------
>>> import pandas as pd
>>> index = pd.MultiIndex.from_tuples([('one', 'a'), ('one', 'b'),
... ('two', 'a'), ('two', 'b')])
>>> s = pd.Series(np.arange(1, 5, dtype=np.int64), index=index)
Expand Down Expand Up @@ -771,7 +770,6 @@ def get_dummies(data, prefix=None, prefix_sep='_', dummy_na=False,

Examples
--------
>>> import pandas as pd
>>> s = pd.Series(list('abca'))

>>> pd.get_dummies(s)
Expand Down
8 changes: 1 addition & 7 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2749,8 +2749,6 @@ def nlargest(self, n=5, keep='first'):

Examples
--------
>>> import pandas as pd
>>> import numpy as np
>>> s = pd.Series(np.random.randn(10**6))
>>> s.nlargest(10) # only sorts up to the N requested
219921 4.644710
Expand Down Expand Up @@ -2796,8 +2794,6 @@ def nsmallest(self, n=5, keep='first'):

Examples
--------
>>> import pandas as pd
>>> import numpy as np
>>> s = pd.Series(np.random.randn(10**6))
>>> s.nsmallest(10) # only sorts up to the N requested
288532 -4.954580
Expand Down Expand Up @@ -3048,7 +3044,7 @@ def _gotitem(self, key, ndim, subset=None):
Examples
--------

>>> s = Series(np.random.randn(10))
>>> s = pd.Series(np.random.randn(10))

>>> s.agg('min')
-1.3018049988556679
Expand Down Expand Up @@ -3127,8 +3123,6 @@ def apply(self, func, convert_dtype=True, args=(), **kwds):

Create a series with typical summer temperatures for each city.

>>> import pandas as pd
>>> import numpy as np
>>> series = pd.Series([20, 21, 12], index=['London',
... 'New York','Helsinki'])
>>> series
Expand Down
17 changes: 8 additions & 9 deletions pandas/core/sparse/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,15 +736,14 @@ def to_coo(self, row_levels=(0, ), column_levels=(1, ), sort_labels=False):

Examples
--------
>>> from numpy import nan
>>> s = Series([3.0, nan, 1.0, 3.0, nan, nan])
>>> s.index = MultiIndex.from_tuples([(1, 2, 'a', 0),
(1, 2, 'a', 1),
(1, 1, 'b', 0),
(1, 1, 'b', 1),
(2, 1, 'b', 0),
(2, 1, 'b', 1)],
names=['A', 'B', 'C', 'D'])
>>> s = pd.Series([3.0, np.nan, 1.0, 3.0, np.nan, np.nan])
>>> s.index = pd.MultiIndex.from_tuples([(1, 2, 'a', 0),
(1, 2, 'a', 1),
(1, 1, 'b', 0),
(1, 1, 'b', 1),
(2, 1, 'b', 0),
(2, 1, 'b', 1)],
names=['A', 'B', 'C', 'D'])
>>> ss = s.to_sparse()
>>> A, rows, columns = ss.to_coo(row_levels=['A', 'B'],
column_levels=['C', 'D'],
Expand Down
1 change: 0 additions & 1 deletion pandas/core/tools/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def to_numeric(arg, errors='raise', downcast=None):
--------
Take separate series and convert to numeric, coercing when told to

>>> import pandas as pd
>>> s = pd.Series(['1.0', '2', -3])
>>> pd.to_numeric(s)
0 1.0
Expand Down
4 changes: 1 addition & 3 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,7 @@ class HDFStore(StringMixin):

Examples
--------
>>> from pandas import DataFrame
>>> from numpy.random import randn
>>> bar = DataFrame(randn(10, 4))
>>> bar = pd.DataFrame(np.random.randn(10, 4))
>>> store = HDFStore('test.h5')
>>> store['foo'] = bar # write to HDF5
>>> bar = store['foo'] # retrieve
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/sas/sas_xport.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@
--------
Read a SAS Xport file:

>>> df = pandas.read_sas('filename.XPT')
>>> df = pd.read_sas('filename.XPT')

Read a Xport file in 10,000 line chunks:

>>> itr = pandas.read_sas('filename.XPT', chunksize=10000)
>>> itr = pd.read_sas('filename.XPT', chunksize=10000)
>>> for chunk in itr:
>>> do_something(chunk)

Expand Down
4 changes: 0 additions & 4 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
--------
Read a Stata dta file:

>>> import pandas as pd
>>> df = pd.read_stata('filename.dta')

Read a Stata dta file in 10,000 line chunks:
Expand Down Expand Up @@ -216,7 +215,6 @@ def _stata_elapsed_date_to_datetime_vec(dates, fmt):

Examples
--------
>>> import pandas as pd
>>> dates = pd.Series([52])
>>> _stata_elapsed_date_to_datetime_vec(dates , "%tw")
0 1961-01-01
Expand Down Expand Up @@ -1946,7 +1944,6 @@ class StataWriter(StataParser):

Examples
--------
>>> import pandas as pd
>>> data = pd.DataFrame([[1.0, 1]], columns=['a', 'b'])
>>> writer = StataWriter('./data_file.dta', data)
>>> writer.write_file()
Expand Down Expand Up @@ -2709,7 +2706,6 @@ class StataWriter117(StataWriter):

Examples
--------
>>> import pandas as pd
>>> from pandas.io.stata import StataWriter117
>>> data = pd.DataFrame([[1.0, 1, 'a']], columns=['a', 'b', 'c'])
>>> writer = StataWriter117('./data_file.dta', data)
Expand Down
7 changes: 2 additions & 5 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2609,14 +2609,11 @@ def boxplot_frame_groupby(grouped, subplots=True, column=None, fontsize=None,

Examples
--------
>>> import pandas
>>> import numpy as np
>>> import itertools
>>>
>>> tuples = [t for t in itertools.product(range(1000), range(4))]
>>> index = pandas.MultiIndex.from_tuples(tuples, names=['lvl0', 'lvl1'])
>>> index = pd.MultiIndex.from_tuples(tuples, names=['lvl0', 'lvl1'])
>>> data = np.random.randn(len(index),4)
>>> df = pandas.DataFrame(data, columns=list('ABCD'), index=index)
>>> df = pd.DataFrame(data, columns=list('ABCD'), index=index)
>>>
>>> grouped = df.groupby(level='lvl1')
>>> boxplot_frame_groupby(grouped)
Expand Down
11 changes: 4 additions & 7 deletions pandas/plotting/_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ def bootstrap_plot(series, fig=None, size=50, samples=500, **kwds):
.. plot::
:context: close-figs

>>> import numpy as np
>>> s = pd.Series(np.random.uniform(size=100))
>>> fig = pd.plotting.bootstrap_plot(s)
"""
Expand Down Expand Up @@ -498,13 +497,11 @@ def parallel_coordinates(frame, class_column, cols=None, ax=None, color=None,

Examples
--------
>>> from pandas import read_csv
>>> from pandas.tools.plotting import parallel_coordinates
>>> from matplotlib import pyplot as plt
>>> df = read_csv('https://raw.github.com/pandas-dev/pandas/master'
'/pandas/tests/data/iris.csv')
>>> parallel_coordinates(df, 'Name', color=('#556270',
'#4ECDC4', '#C7F464'))
>>> df = pd.read_csv('https://raw.github.com/pandas-dev/pandas/master'
'/pandas/tests/data/iris.csv')
>>> pd.plotting.parallel_coordinates(df, 'Name',
color=('#556270', '#4ECDC4', '#C7F464'))
>>> plt.show()
"""
if axvlines_kwds is None:
Expand Down
5 changes: 2 additions & 3 deletions pandas/tseries/holiday.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,11 @@ class from pandas.tseries.offsets
Examples
--------
>>> from pandas.tseries.holiday import Holiday, nearest_workday
>>> from pandas import DateOffset
>>> from dateutil.relativedelta import MO
>>> USMemorialDay = Holiday('MemorialDay', month=5, day=24,
offset=DateOffset(weekday=MO(1)))
offset=pd.DateOffset(weekday=MO(1)))
>>> USLaborDay = Holiday('Labor Day', month=9, day=1,
offset=DateOffset(weekday=MO(1)))
offset=pd.DateOffset(weekday=MO(1)))
>>> July3rd = Holiday('July 3rd', month=7, day=3,)
>>> NewYears = Holiday('New Years Day', month=1, day=1,
observance=nearest_workday),
Expand Down