Last active
January 31, 2018 15:06
-
-
Save TobCap/9ea248d05712062e0d496038afa7e8d2 to your computer and use it in GitHub Desktop.
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
$ python --version | |
Python 3.6.0 :: Anaconda 4.3.1 (x86_64) | |
$ python -c "import pandas as pd; print(pd.__version__)" | |
0.19.2 | |
$ python | |
Python 3.6.0 |Anaconda 4.3.1 (x86_64)| (default, Dec 23 2016, 13:19:00) | |
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> exam1(False) | |
rise_error=False | |
>>> exam1(True) | |
rise_error=True | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
File "<stdin>", line 11, in exam1 | |
File "/Users/kmkm/.pyenv/versions/anaconda3-4.3.1/lib/python3.6/site-packages/pandas/core/frame.py", line 4555, in join | |
rsuffix=rsuffix, sort=sort) | |
File "/Users/kmkm/.pyenv/versions/anaconda3-4.3.1/lib/python3.6/site-packages/pandas/core/frame.py", line 4569, in _join_compat | |
suffixes=(lsuffix, rsuffix), sort=sort) | |
File "/Users/kmkm/.pyenv/versions/anaconda3-4.3.1/lib/python3.6/site-packages/pandas/tools/merge.py", line 62, in merge | |
return op.get_result() | |
File "/Users/kmkm/.pyenv/versions/anaconda3-4.3.1/lib/python3.6/site-packages/pandas/tools/merge.py", line 564, in get_result | |
concat_axis=0, copy=self.copy) | |
File "/Users/kmkm/.pyenv/versions/anaconda3-4.3.1/lib/python3.6/site-packages/pandas/core/internals.py", line 4825, in concatenate_block_managers | |
placement=placement) for placement, join_units in concat_plan] | |
File "/Users/kmkm/.pyenv/versions/anaconda3-4.3.1/lib/python3.6/site-packages/pandas/core/internals.py", line 4825, in <listcomp> | |
placement=placement) for placement, join_units in concat_plan] | |
File "/Users/kmkm/.pyenv/versions/anaconda3-4.3.1/lib/python3.6/site-packages/pandas/core/internals.py", line 4922, in concatenate_join_units | |
for ju in join_units] | |
File "/Users/kmkm/.pyenv/versions/anaconda3-4.3.1/lib/python3.6/site-packages/pandas/core/internals.py", line 4922, in <listcomp> | |
for ju in join_units] | |
File "/Users/kmkm/.pyenv/versions/anaconda3-4.3.1/lib/python3.6/site-packages/pandas/core/internals.py", line 5222, in get_reindexed_values | |
fill_value=fill_value) | |
File "/Users/kmkm/.pyenv/versions/anaconda3-4.3.1/lib/python3.6/site-packages/pandas/core/algorithms.py", line 1045, in take_nd | |
return arr.take(indexer, fill_value=fill_value, allow_fill=allow_fill) | |
File "/Users/kmkm/.pyenv/versions/anaconda3-4.3.1/lib/python3.6/site-packages/pandas/tseries/base.py", line 379, in take | |
na_value=tslib.iNaT) | |
File "/Users/kmkm/.pyenv/versions/anaconda3-4.3.1/lib/python3.6/site-packages/pandas/indexes/base.py", line 1534, in _assert_take_fillable | |
taken = values.take(indices) | |
IndexError: cannot do a non-empty take from an empty axes. |
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
import pandas as pd | |
def exam1(rise_error=False): | |
print('rise_error={0}'.format(rise_error)) | |
t0_idx0 = pd.Index(data=['test_user1'], names=['id']) | |
t0_df0 = pd.DataFrame(index=t0_idx0) | |
t1_idx1 = pd.Index(data=[], names=['id']) | |
t1_df1 = pd.DataFrame(index=t1_idx1, columns=['col1'], data=pd.to_datetime([])) | |
if rise_error: | |
t1_df1.col1 = t1_df1.col1.dt.tz_localize('utc').dt.tz_convert('Asia/Tokyo') | |
t0_df0.join(t1_df1) | |
exam1(False) | |
exam1(True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment