PageRenderTime 50ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/pandas/computation/common.py

http://github.com/pydata/pandas
Python | 24 lines | 14 code | 6 blank | 4 comment | 3 complexity | ba3da092b6f524349ebd066ba3b6f67b MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0
  1. import numpy as np
  2. import pandas as pd
  3. from pandas.compat import reduce
  4. def _ensure_decoded(s):
  5. """ if we have bytes, decode them to unicode """
  6. if isinstance(s, (np.bytes_, bytes)):
  7. s = s.decode(pd.get_option('display.encoding'))
  8. return s
  9. def _result_type_many(*arrays_and_dtypes):
  10. """ wrapper around numpy.result_type which overcomes the NPY_MAXARGS (32)
  11. argument limit """
  12. try:
  13. return np.result_type(*arrays_and_dtypes)
  14. except ValueError:
  15. # we have > NPY_MAXARGS terms in our expression
  16. return reduce(np.result_type, arrays_and_dtypes)
  17. class NameResolutionError(NameError):
  18. pass