original_docstring: r"""Prepare a python object for transformation in R.
  
          Args:
              pyobj (object): Python object.
  
          Returns:
              object: Python object in a form that is R friendly.
  
          
docstring: r"""Prepare a python object for transformation in R.
docstring_tokens: r " " " Prepare a python object for transformation in R .
code: def python2language(cls, pyobj):
          r"""Prepare a python object for transformation in R.
  
          Args:
              pyobj (object): Python object.
  
          Returns:
              object: Python object in a form that is R friendly.
  
          """
          logger.debug("python2language: %s, %s" % (pyobj, type(pyobj)))
          if isinstance(pyobj, tuple):
              return tuple([cls.python2language(x) for x in pyobj])
          elif isinstance(pyobj, list):
              return [cls.python2language(x) for x in pyobj]
          elif isinstance(pyobj, OrderedDict):
              return OrderedDict([(cls.python2language(k),
                                   cls.python2language(v))
                                  for k, v in pyobj.items()])
          elif isinstance(pyobj, dict):
              return {cls.python2language(k): cls.python2language(v)
                      for k, v in pyobj.items()}
          elif isinstance(pyobj, np.string_):
              return pyobj.decode("utf-8")
          elif isinstance(pyobj, pd.DataFrame):
              # R dosn't have int64 and will cast 64bit ints as floats if passed
              # without casting them to int32 first
              for n in pyobj.columns:
                  if pyobj[n].dtype == np.dtype('int64'):
                      pyobj[n] = pyobj[n].astype('int32')
          return pyobj
code_tokens: def python2language ( cls , pyobj ) : logger . debug ( "python2language: %s, %s" % ( pyobj , type ( pyobj ) ) ) if isinstance ( pyobj , tuple ) : return tuple ( [ cls . python2language ( x ) for x in pyobj ] ) elif isinstance ( pyobj , list ) : return [ cls . python2language ( x ) for x in pyobj ] elif isinstance ( pyobj , OrderedDict ) : return OrderedDict ( [ ( cls . python2language ( k ) , cls . python2language ( v ) ) for k , v in pyobj . items ( ) ] ) elif isinstance ( pyobj , dict ) : return { cls . python2language ( k ) : cls . python2language ( v ) for k , v in pyobj . items ( ) } elif isinstance ( pyobj , np . string_ ) : return pyobj . decode ( "utf-8" ) elif isinstance ( pyobj , pd . DataFrame ) : for n in pyobj . columns : if pyobj [ n ] . dtype == np . dtype ( 'int64' ) : pyobj [ n ] = pyobj [ n ] . astype ( 'int32' ) return pyobj
short_docstring: r"""Prepare a python object for transformation in R.
short_docstring_tokens: r " " " Prepare a python object for transformation in R .
comment: r"""Prepare a python object for transformation in R.
  
          Args:
              pyobj (object): Python object.
  
          Returns:
              object: Python object in a form that is R friendly.
  
          """$SEP$# R dosn't have int64 and will cast 64bit ints as floats if passed$SEP$# without casting them to int32 first