-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- closes #8596, preserve join keys dtype - adds ``Index.where`` method for all Index types (like ``np.where/Series.where``), but preserves dtypes Author: Jeff Reback <jeff@reback.net> Author: Mike Kelly <mtk@numeric.com> Closes #13170 from jreback/merge2 and squashes the following commits: 0a267cf [Jeff Reback] BUG: preserve merge keys dtypes when possible 4173dbf [Mike Kelly] Preserve dtype in merge keys when possible
- Loading branch information
Showing
14 changed files
with
464 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- coding: utf-8 -*- | ||
import nose | ||
import numpy as np | ||
|
||
from pandas import NaT | ||
from pandas.types.api import (DatetimeTZDtype, CategoricalDtype, | ||
na_value_for_dtype, pandas_dtype) | ||
|
||
|
||
def test_pandas_dtype(): | ||
|
||
assert pandas_dtype('datetime64[ns, US/Eastern]') == DatetimeTZDtype( | ||
'datetime64[ns, US/Eastern]') | ||
assert pandas_dtype('category') == CategoricalDtype() | ||
for dtype in ['M8[ns]', 'm8[ns]', 'object', 'float64', 'int64']: | ||
assert pandas_dtype(dtype) == np.dtype(dtype) | ||
|
||
|
||
def test_na_value_for_dtype(): | ||
for dtype in [np.dtype('M8[ns]'), np.dtype('m8[ns]'), | ||
DatetimeTZDtype('datetime64[ns, US/Eastern]')]: | ||
assert na_value_for_dtype(dtype) is NaT | ||
|
||
for dtype in ['u1', 'u2', 'u4', 'u8', | ||
'i1', 'i2', 'i4', 'i8']: | ||
assert na_value_for_dtype(np.dtype(dtype)) == 0 | ||
|
||
for dtype in ['bool']: | ||
assert na_value_for_dtype(np.dtype(dtype)) is False | ||
|
||
for dtype in ['f2', 'f4', 'f8']: | ||
assert np.isnan(na_value_for_dtype(np.dtype(dtype))) | ||
|
||
for dtype in ['O']: | ||
assert np.isnan(na_value_for_dtype(np.dtype(dtype))) | ||
|
||
|
||
if __name__ == '__main__': | ||
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'], | ||
exit=False) |
Oops, something went wrong.