Here are the examples of the python api numpy.int64 taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
145 Examples
3
View Complete Implementation : test_period.py
Copyright Apache License 2.0
Author : Frank-qlu
Copyright Apache License 2.0
Author : Frank-qlu
@pytest.mark.parametrize("data, freq, expected", [
([pd.Period("2017", "D")], None, [17167]),
([pd.Period("2017", "D")], "D", [17167]),
([2017], "D", [17167]),
(["2017"], "D", [17167]),
([pd.Period("2017", "D")], pd.tseries.offsets.Day(), [17167]),
([pd.Period("2017", "D"), None], None, [17167, iNaT]),
(pd.Series(pd.date_range("2017", periods=3)), None,
[17167, 17168, 17169]),
(pd.date_range("2017", periods=3), None, [17167, 17168, 17169]),
])
def test_period_array_ok(data, freq, expected):
result = period_array(data, freq=freq).asi8
expected = np.asarray(expected, dtype=np.int64)
tm.astert_numpy_array_equal(result, expected)
3
View Complete Implementation : test_join.py
Copyright Apache License 2.0
Author : Frank-qlu
Copyright Apache License 2.0
Author : Frank-qlu
def test_left_join_indexer2():
idx = Index([1, 1, 2, 5])
idx2 = Index([1, 2, 5, 7, 9])
res, lidx, ridx = _join.left_join_indexer_int64(idx2.values, idx.values)
exp_res = np.array([1, 1, 2, 5, 7, 9], dtype=np.int64)
astert_almost_equal(res, exp_res)
exp_lidx = np.array([0, 0, 1, 2, 3, 4], dtype=np.int64)
astert_almost_equal(lidx, exp_lidx)
exp_ridx = np.array([0, 1, 2, 3, -1, -1], dtype=np.int64)
astert_almost_equal(ridx, exp_ridx)
3
View Complete Implementation : test_period_index.py
Copyright Apache License 2.0
Author : Frank-qlu
Copyright Apache License 2.0
Author : Frank-qlu
@pytest.mark.parametrize('freq', ['H', '12H', '2D', 'W'])
@pytest.mark.parametrize('kind', [None, 'period', 'timestamp'])
def test_selection(self, index, freq, kind):
# This is a bug, these should be implemented
# GH 14008
rng = np.arange(len(index), dtype=np.int64)
df = DataFrame({'date': index, 'a': rng},
index=pd.MultiIndex.from_arrays([rng, index],
names=['v', 'd']))
with pytest.raises(NotImplementedError):
df.resample(freq, on='date', kind=kind)
with pytest.raises(NotImplementedError):
df.resample(freq, level='d', kind=kind)
3
View Complete Implementation : test_nanops.py
Copyright Apache License 2.0
Author : Frank-qlu
Copyright Apache License 2.0
Author : Frank-qlu
def test_nanmean_overflow(self):
# GH 10155
# In the previous implementation mean can overflow for int dtypes, it
# is now consistent with numpy
for a in [2 ** 55, -2 ** 55, 20150515061816532]:
s = Series(a, index=range(500), dtype=np.int64)
result = s.mean()
np_result = s.values.mean()
astert result == a
astert result == np_result
astert result.dtype == np.float64
3
View Complete Implementation : test_nanops.py
Copyright Apache License 2.0
Author : Frank-qlu
Copyright Apache License 2.0
Author : Frank-qlu
def test_nanmean_overflow(self):
# GH 10155
# In the previous implementation mean can overflow for int dtypes, it
# is now consistent with numpy
for a in [2 ** 55, -2 ** 55, 20150515061816532]:
s = Series(a, index=range(500), dtype=np.int64)
result = s.mean()
np_result = s.values.mean()
astert result == a
astert result == np_result
astert result.dtype == np.float64
3
View Complete Implementation : test_axis_select_reindex.py
Copyright Apache License 2.0
Author : Frank-qlu
Copyright Apache License 2.0
Author : Frank-qlu
def test_reindex_int(self):
smaller = self.intframe.reindex(self.intframe.index[::2])
astert smaller['A'].dtype == np.int64
bigger = smaller.reindex(self.intframe.index)
astert bigger['A'].dtype == np.float64
smaller = self.intframe.reindex(columns=['A', 'B'])
astert smaller['A'].dtype == np.int64
3
View Complete Implementation : test_join.py
Copyright Apache License 2.0
Author : Frank-qlu
Copyright Apache License 2.0
Author : Frank-qlu
def test_outer_join_indexer2():
idx = Index([1, 1, 2, 5])
idx2 = Index([1, 2, 5, 7, 9])
res, lidx, ridx = _join.outer_join_indexer_int64(idx2.values, idx.values)
exp_res = np.array([1, 1, 2, 5, 7, 9], dtype=np.int64)
astert_almost_equal(res, exp_res)
exp_lidx = np.array([0, 0, 1, 2, 3, 4], dtype=np.int64)
astert_almost_equal(lidx, exp_lidx)
exp_ridx = np.array([0, 1, 2, 3, -1, -1], dtype=np.int64)
astert_almost_equal(ridx, exp_ridx)
3
View Complete Implementation : test_timezones.py
Copyright Apache License 2.0
Author : Frank-qlu
Copyright Apache License 2.0
Author : Frank-qlu
@pytest.mark.parametrize('prefix', ['', 'dateutil/'])
def test_field_access_localize(self, prefix):
strdates = ['1/1/2012', '3/1/2012', '4/1/2012']
rng = DatetimeIndex(strdates, tz=prefix + 'US/Eastern')
astert (rng.hour == 0).all()
# a more unusual time zone, #1946
dr = date_range('2011-10-02 00:00', freq='h', periods=10,
tz=prefix + 'America/Atikokan')
expected = Index(np.arange(10, dtype=np.int64))
tm.astert_index_equal(dr.hour, expected)
3
View Complete Implementation : test_period.py
Copyright Apache License 2.0
Author : Frank-qlu
Copyright Apache License 2.0
Author : Frank-qlu
def test_view_asi8(self):
idx = pd.PeriodIndex([], freq='M')
exp = np.array([], dtype=np.int64)
tm.astert_numpy_array_equal(idx.view('i8'), exp)
tm.astert_numpy_array_equal(idx.asi8, exp)
idx = pd.PeriodIndex(['2011-01', pd.NaT], freq='M')
exp = np.array([492, -9223372036854775808], dtype=np.int64)
tm.astert_numpy_array_equal(idx.view('i8'), exp)
tm.astert_numpy_array_equal(idx.asi8, exp)
exp = np.array([14975, -9223372036854775808], dtype=np.int64)
idx = pd.PeriodIndex(['2011-01-01', pd.NaT], freq='D')
tm.astert_numpy_array_equal(idx.view('i8'), exp)
tm.astert_numpy_array_equal(idx.asi8, exp)
3
View Complete Implementation : test_sorting.py
Copyright Apache License 2.0
Author : Frank-qlu
Copyright Apache License 2.0
Author : Frank-qlu
def test_decons():
def tessat(label_list, shape):
group_index = get_group_index(label_list, shape, sort=True, xnull=True)
label_list2 = decons_group_index(group_index, shape)
for a, b in zip(label_list, label_list2):
tm.astert_numpy_array_equal(a, b)
shape = (4, 5, 6)
label_list = [np.tile([0, 1, 2, 3, 0, 1, 2, 3], 100).astype(np.int64),
np.tile([0, 2, 4, 3, 0, 1, 2, 3], 100).astype(np.int64),
np.tile([5, 1, 0, 2, 3, 0, 5, 4], 100).astype(np.int64)]
tessat(label_list, shape)
shape = (10000, 10000)
label_list = [np.tile(np.arange(10000, dtype=np.int64), 5),
np.tile(np.arange(10000, dtype=np.int64), 5)]
tessat(label_list, shape)