diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 7b5f310315485..d192b32b26bdb 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -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}}) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 818dd1b408518..251bdcf76355a 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -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 diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index c69d7f43de8ea..e973608507a29 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -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], @@ -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], diff --git a/pandas/core/panel.py b/pandas/core/panel.py index e012819812f6b..9f08fabef8cc7 100644 --- a/pandas/core/panel.py +++ b/pandas/core/panel.py @@ -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) diff --git a/pandas/core/reshape/melt.py b/pandas/core/reshape/melt.py index b3e3c52f6e363..f4b96c8f1ca49 100644 --- a/pandas/core/reshape/melt.py +++ b/pandas/core/reshape/melt.py @@ -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]}) @@ -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"}, diff --git a/pandas/core/reshape/reshape.py b/pandas/core/reshape/reshape.py index 3d9e84954a63b..089634fb8e315 100644 --- a/pandas/core/reshape/reshape.py +++ b/pandas/core/reshape/reshape.py @@ -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) @@ -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) diff --git a/pandas/core/series.py b/pandas/core/series.py index 93c1f866cad17..10a08dc5e0cde 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/pandas/core/sparse/series.py b/pandas/core/sparse/series.py index 09d958059d355..f6428568a6383 100644 --- a/pandas/core/sparse/series.py +++ b/pandas/core/sparse/series.py @@ -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'], diff --git a/pandas/core/tools/numeric.py b/pandas/core/tools/numeric.py index ebe135dfb184c..f1d13ccf36cf6 100644 --- a/pandas/core/tools/numeric.py +++ b/pandas/core/tools/numeric.py @@ -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 diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index f93ad425b2c6a..374114d2b014b 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -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 diff --git a/pandas/io/sas/sas_xport.py b/pandas/io/sas/sas_xport.py index 7994517b9f303..cb01b7a652157 100644 --- a/pandas/io/sas/sas_xport.py +++ b/pandas/io/sas/sas_xport.py @@ -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) diff --git a/pandas/io/stata.py b/pandas/io/stata.py index b2a5bec2a4837..c3af5d214317a 100644 --- a/pandas/io/stata.py +++ b/pandas/io/stata.py @@ -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: @@ -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 @@ -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() @@ -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) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 0fb1f2b23faac..842da838b4b83 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -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) diff --git a/pandas/plotting/_misc.py b/pandas/plotting/_misc.py index 150c9274d4e5c..84e545a3ca2f2 100644 --- a/pandas/plotting/_misc.py +++ b/pandas/plotting/_misc.py @@ -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) """ @@ -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: diff --git a/pandas/tseries/holiday.py b/pandas/tseries/holiday.py index 4e874eac9e6c6..33dcf6d64b302 100644 --- a/pandas/tseries/holiday.py +++ b/pandas/tseries/holiday.py @@ -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),