當前位置: 首頁>>代碼示例>>Python>>正文


Python testing.makeDateIndex方法代碼示例

本文整理匯總了Python中pandas.util.testing.makeDateIndex方法的典型用法代碼示例。如果您正苦於以下問題:Python testing.makeDateIndex方法的具體用法?Python testing.makeDateIndex怎麽用?Python testing.makeDateIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pandas.util.testing的用法示例。


在下文中一共展示了testing.makeDateIndex方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setup_method

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeDateIndex [as 別名]
def setup_method(self, method):
        self.indices = dict(unicodeIndex=tm.makeUnicodeIndex(100),
                            strIndex=tm.makeStringIndex(100),
                            dateIndex=tm.makeDateIndex(100),
                            periodIndex=tm.makePeriodIndex(100),
                            tdIndex=tm.makeTimedeltaIndex(100),
                            intIndex=tm.makeIntIndex(100),
                            uintIndex=tm.makeUIntIndex(100),
                            rangeIndex=tm.makeRangeIndex(100),
                            floatIndex=tm.makeFloatIndex(100),
                            boolIndex=Index([True, False]),
                            catIndex=tm.makeCategoricalIndex(100),
                            empty=Index([]),
                            tuples=MultiIndex.from_tuples(lzip(
                                ['foo', 'bar', 'baz'], [1, 2, 3])),
                            repeats=Index([0, 0, 1, 1, 2, 2]))
        self.setup_indices() 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:19,代碼來源:test_base.py

示例2: test_intersection2

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeDateIndex [as 別名]
def test_intersection2(self):
        first = tm.makeDateIndex(10)
        second = first[5:]
        intersect = first.intersection(second)
        assert tm.equalContents(intersect, second)

        # GH 10149
        cases = [klass(second.values) for klass in [np.array, Series, list]]
        for case in cases:
            result = first.intersection(case)
            assert tm.equalContents(result, second)

        third = Index(['a', 'b', 'c'])
        result = first.intersection(third)
        expected = pd.Index([], dtype=object)
        tm.assert_index_equal(result, expected) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:18,代碼來源:test_setops.py

示例3: test_line_area_nan_series

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeDateIndex [as 別名]
def test_line_area_nan_series(self):
        values = [1, 2, np.nan, 3]
        s = Series(values)
        ts = Series(values, index=tm.makeDateIndex(k=4))

        for d in [s, ts]:
            ax = _check_plot_works(d.plot)
            masked = ax.lines[0].get_ydata()
            # remove nan for comparison purpose
            exp = np.array([1, 2, 3], dtype=np.float64)
            tm.assert_numpy_array_equal(np.delete(masked.data, 2), exp)
            tm.assert_numpy_array_equal(
                masked.mask, np.array([False, False, True, False]))

            expected = np.array([1, 2, 0, 3], dtype=np.float64)
            ax = _check_plot_works(d.plot, stacked=True)
            tm.assert_numpy_array_equal(ax.lines[0].get_ydata(), expected)
            ax = _check_plot_works(d.plot.area)
            tm.assert_numpy_array_equal(ax.lines[0].get_ydata(), expected)
            ax = _check_plot_works(d.plot.area, stacked=False)
            tm.assert_numpy_array_equal(ax.lines[0].get_ydata(), expected) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:23,代碼來源:test_series.py

示例4: get_objs

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeDateIndex [as 別名]
def get_objs():
    indexes = [
        tm.makeBoolIndex(10, name='a'),
        tm.makeIntIndex(10, name='a'),
        tm.makeFloatIndex(10, name='a'),
        tm.makeDateIndex(10, name='a'),
        tm.makeDateIndex(10, name='a').tz_localize(tz='US/Eastern'),
        tm.makePeriodIndex(10, name='a'),
        tm.makeStringIndex(10, name='a'),
        tm.makeUnicodeIndex(10, name='a')
    ]

    arr = np.random.randn(10)
    series = [Series(arr, index=idx, name='a') for idx in indexes]

    objs = indexes + series
    return objs 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:19,代碼來源:test_reductions.py

示例5: setup_method

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeDateIndex [as 別名]
def setup_method(self, method):
        super(TestIndex, self).setup_method(method)

        self.d = {
            'string': tm.makeStringIndex(100),
            'date': tm.makeDateIndex(100),
            'int': tm.makeIntIndex(100),
            'rng': tm.makeRangeIndex(100),
            'float': tm.makeFloatIndex(100),
            'empty': Index([]),
            'tuple': Index(zip(['foo', 'bar', 'baz'], [1, 2, 3])),
            'period': Index(period_range('2012-1-1', freq='M', periods=3)),
            'date2': Index(date_range('2013-01-1', periods=10)),
            'bdate': Index(bdate_range('2013-01-02', periods=10)),
            'cat': tm.makeCategoricalIndex(100),
            'interval': tm.makeIntervalIndex(100),
            'timedelta': tm.makeTimedeltaIndex(100, 'H')
        }

        self.mi = {
            'reg': MultiIndex.from_tuples([('bar', 'one'), ('baz', 'two'),
                                           ('foo', 'two'),
                                           ('qux', 'one'), ('qux', 'two')],
                                          names=['first', 'second']),
        } 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:27,代碼來源:test_packers.py

示例6: setup_method

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeDateIndex [as 別名]
def setup_method(self, method):
        self.bool_index = tm.makeBoolIndex(10, name='a')
        self.int_index = tm.makeIntIndex(10, name='a')
        self.float_index = tm.makeFloatIndex(10, name='a')
        self.dt_index = tm.makeDateIndex(10, name='a')
        self.dt_tz_index = tm.makeDateIndex(10, name='a').tz_localize(
            tz='US/Eastern')
        self.period_index = tm.makePeriodIndex(10, name='a')
        self.string_index = tm.makeStringIndex(10, name='a')
        self.unicode_index = tm.makeUnicodeIndex(10, name='a')

        arr = np.random.randn(10)
        self.int_series = Series(arr, index=self.int_index, name='a')
        self.float_series = Series(arr, index=self.float_index, name='a')
        self.dt_series = Series(arr, index=self.dt_index, name='a')
        self.dt_tz_series = self.dt_tz_index.to_series(keep_tz=True)
        self.period_series = Series(arr, index=self.period_index, name='a')
        self.string_series = Series(arr, index=self.string_index, name='a')

        types = ['bool', 'int', 'float', 'dt', 'dt_tz', 'period', 'string',
                 'unicode']
        fmts = ["{0}_{1}".format(t, f)
                for t in types for f in ['index', 'series']]
        self.objs = [getattr(self, f)
                     for f in fmts if getattr(self, f, None) is not None] 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:27,代碼來源:test_base.py

示例7: test_tseries_indices_series

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeDateIndex [as 別名]
def test_tseries_indices_series(self):

        with ensure_clean_store(self.path) as store:
            idx = tm.makeDateIndex(10)
            ser = Series(np.random.randn(len(idx)), idx)
            store['a'] = ser
            result = store['a']

            assert_series_equal(result, ser)
            self.assertEquals(type(result.index), type(ser.index))
            self.assertEquals(result.index.freq, ser.index.freq)

            idx = tm.makePeriodIndex(10)
            ser = Series(np.random.randn(len(idx)), idx)
            store['a'] = ser
            result = store['a']

            assert_series_equal(result, ser)
            self.assertEquals(type(result.index), type(ser.index))
            self.assertEquals(result.index.freq, ser.index.freq) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:22,代碼來源:test_pytables.py

示例8: test_tseries_indices_frame

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeDateIndex [as 別名]
def test_tseries_indices_frame(self):

        with ensure_clean_store(self.path) as store:
            idx = tm.makeDateIndex(10)
            df = DataFrame(np.random.randn(len(idx), 3), index=idx)
            store['a'] = df
            result = store['a']

            assert_frame_equal(result, df)
            self.assertEquals(type(result.index), type(df.index))
            self.assertEquals(result.index.freq, df.index.freq)

            idx = tm.makePeriodIndex(10)
            df = DataFrame(np.random.randn(len(idx), 3), idx)
            store['a'] = df
            result = store['a']

            assert_frame_equal(result, df)
            self.assertEquals(type(result.index), type(df.index))
            self.assertEquals(result.index.freq, df.index.freq) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:22,代碼來源:test_pytables.py

示例9: setup_method

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeDateIndex [as 別名]
def setup_method(self, method):
        self.indices = dict(unicodeIndex=tm.makeUnicodeIndex(100),
                            strIndex=tm.makeStringIndex(100),
                            dateIndex=tm.makeDateIndex(100),
                            periodIndex=tm.makePeriodIndex(100),
                            tdIndex=tm.makeTimedeltaIndex(100),
                            intIndex=tm.makeIntIndex(100),
                            uintIndex=tm.makeUIntIndex(100),
                            rangeIndex=tm.makeIntIndex(100),
                            floatIndex=tm.makeFloatIndex(100),
                            boolIndex=Index([True, False]),
                            catIndex=tm.makeCategoricalIndex(100),
                            empty=Index([]),
                            tuples=MultiIndex.from_tuples(lzip(
                                ['foo', 'bar', 'baz'], [1, 2, 3])),
                            repeats=Index([0, 0, 1, 1, 2, 2]))
        self.setup_indices() 
開發者ID:securityclippy,項目名稱:elasticintel,代碼行數:19,代碼來源:test_base.py

示例10: test_map_tseries_indices_accsr_return_index

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeDateIndex [as 別名]
def test_map_tseries_indices_accsr_return_index(self):
        date_index = tm.makeDateIndex(24, freq='h', name='hourly')
        expected = Index(range(24), name='hourly')
        tm.assert_index_equal(expected, date_index.map(lambda x: x.hour)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:6,代碼來源:test_base.py

示例11: test_outer_join_sort

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeDateIndex [as 別名]
def test_outer_join_sort(self):
        left_index = Index(np.random.permutation(15))
        right_index = tm.makeDateIndex(10)

        with tm.assert_produces_warning(RuntimeWarning):
            result = left_index.join(right_index, how='outer')

        # right_index in this case because DatetimeIndex has join precedence
        # over Int64Index
        with tm.assert_produces_warning(RuntimeWarning):
            expected = right_index.astype(object).union(
                left_index.astype(object))

        tm.assert_index_equal(result, expected) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:16,代碼來源:test_base.py

示例12: test_dti_timestamp_fields

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeDateIndex [as 別名]
def test_dti_timestamp_fields(self, field):
        # extra fields from DatetimeIndex like quarter and week
        idx = tm.makeDateIndex(100)
        expected = getattr(idx, field)[-1]
        if field == 'weekday_name':
            with tm.assert_produces_warning(FutureWarning,
                                            check_stacklevel=False):
                result = getattr(Timestamp(idx[-1]), field)
        else:
            result = getattr(Timestamp(idx[-1]), field)
        assert result == expected 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:13,代碼來源:test_scalar_compat.py

示例13: test_dti_timestamp_freq_fields

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeDateIndex [as 別名]
def test_dti_timestamp_freq_fields(self):
        # extra fields from DatetimeIndex like quarter and week
        idx = tm.makeDateIndex(100)

        assert idx.freq == Timestamp(idx[-1], idx.freq).freq
        assert idx.freqstr == Timestamp(idx[-1], idx.freq).freqstr

    # ----------------------------------------------------------------
    # DatetimeIndex.round 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:11,代碼來源:test_scalar_compat.py

示例14: test_isin

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeDateIndex [as 別名]
def test_isin(self):
        index = tm.makeDateIndex(4)
        result = index.isin(index)
        assert result.all()

        result = index.isin(list(index))
        assert result.all()

        assert_almost_equal(index.isin([index[2], 5]),
                            np.array([False, False, True, False])) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:12,代碼來源:test_datetime.py

示例15: setup_method

# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import makeDateIndex [as 別名]
def setup_method(self, method):
        self.indices = dict(index=tm.makeDateIndex(10),
                            index_dec=date_range('20130110', periods=10,
                                                 freq='-1D'))
        self.setup_indices() 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:7,代碼來源:test_datetimelike.py


注:本文中的pandas.util.testing.makeDateIndex方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。