当前位置: 首页>>代码示例>>Python>>正文


Python common._stringify_path方法代码示例

本文整理汇总了Python中pandas.io.common._stringify_path方法的典型用法代码示例。如果您正苦于以下问题:Python common._stringify_path方法的具体用法?Python common._stringify_path怎么用?Python common._stringify_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pandas.io.common的用法示例。


在下文中一共展示了common._stringify_path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: to_hdf

# 需要导入模块: from pandas.io import common [as 别名]
# 或者: from pandas.io.common import _stringify_path [as 别名]
def to_hdf(path_or_buf, key, value, mode=None, complevel=None, complib=None,
           append=None, **kwargs):
    """ store this object, close it if we opened it """

    if append:
        f = lambda store: store.append(key, value, **kwargs)
    else:
        f = lambda store: store.put(key, value, **kwargs)

    path_or_buf = _stringify_path(path_or_buf)
    if isinstance(path_or_buf, string_types):
        with HDFStore(path_or_buf, mode=mode, complevel=complevel,
                      complib=complib) as store:
            f(store)
    else:
        f(path_or_buf) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:18,代码来源:pytables.py

示例2: test_stringify_path_pathlib

# 需要导入模块: from pandas.io import common [as 别名]
# 或者: from pandas.io.common import _stringify_path [as 别名]
def test_stringify_path_pathlib(self):
        rel_path = icom._stringify_path(Path('.'))
        assert rel_path == '.'
        redundant_path = icom._stringify_path(Path('foo//bar'))
        assert redundant_path == os.path.join('foo', 'bar') 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:test_common.py

示例3: test_stringify_path_localpath

# 需要导入模块: from pandas.io import common [as 别名]
# 或者: from pandas.io.common import _stringify_path [as 别名]
def test_stringify_path_localpath(self):
        path = os.path.join('foo', 'bar')
        abs_path = os.path.abspath(path)
        lpath = LocalPath(path)
        assert icom._stringify_path(lpath) == abs_path 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:test_common.py

示例4: test_stringify_path_fspath

# 需要导入模块: from pandas.io import common [as 别名]
# 或者: from pandas.io.common import _stringify_path [as 别名]
def test_stringify_path_fspath(self):
        p = CustomFSPath('foo/bar.csv')
        result = icom._stringify_path(p)
        assert result == 'foo/bar.csv' 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:6,代码来源:test_common.py

示例5: write

# 需要导入模块: from pandas.io import common [as 别名]
# 或者: from pandas.io.common import _stringify_path [as 别名]
def write(self, writer, sheet_name='Sheet1', startrow=0,
              startcol=0, freeze_panes=None, engine=None):
        """
        writer : string or ExcelWriter object
            File path or existing ExcelWriter
        sheet_name : string, default 'Sheet1'
            Name of sheet which will contain DataFrame
        startrow :
            upper left cell row to dump data frame
        startcol :
            upper left cell column to dump data frame
        freeze_panes : tuple of integer (length 2), default None
            Specifies the one-based bottommost row and rightmost column that
            is to be frozen
        engine : string, default None
            write engine to use if writer is a path - you can also set this
            via the options ``io.excel.xlsx.writer``, ``io.excel.xls.writer``,
            and ``io.excel.xlsm.writer``.
        """
        from pandas.io.excel import ExcelWriter
        from pandas.io.common import _stringify_path

        if isinstance(writer, ExcelWriter):
            need_save = False
        else:
            writer = ExcelWriter(_stringify_path(writer), engine=engine)
            need_save = True

        formatted_cells = self.get_formatted_cells()
        writer.write_cells(formatted_cells, sheet_name,
                           startrow=startrow, startcol=startcol,
                           freeze_panes=freeze_panes)
        if need_save:
            writer.save() 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:36,代码来源:excel.py

示例6: __init__

# 需要导入模块: from pandas.io import common [as 别名]
# 或者: from pandas.io.common import _stringify_path [as 别名]
def __init__(self, path, mode=None, complevel=None, complib=None,
                 fletcher32=False, **kwargs):

        if 'format' in kwargs:
            raise ValueError('format is not a defined argument for HDFStore')

        try:
            import tables  # noqa
        except ImportError as ex:  # pragma: no cover
            raise ImportError('HDFStore requires PyTables, "{ex!s}" problem '
                              'importing'.format(ex=ex))

        if complib is not None and complib not in tables.filters.all_complibs:
            raise ValueError(
                "complib only supports {libs} compression.".format(
                    libs=tables.filters.all_complibs))

        if complib is None and complevel is not None:
            complib = tables.filters.default_complib

        self._path = _stringify_path(path)
        if mode is None:
            mode = 'a'
        self._mode = mode
        self._handle = None
        self._complevel = complevel if complevel else 0
        self._complib = complib
        self._fletcher32 = fletcher32
        self._filters = None
        self.open(mode=mode, **kwargs) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:32,代码来源:pytables.py

示例7: read_feather

# 需要导入模块: from pandas.io import common [as 别名]
# 或者: from pandas.io.common import _stringify_path [as 别名]
def read_feather(path, columns=None, use_threads=True):
    """
    Load a feather-format object from the file path

    .. versionadded 0.20.0

    Parameters
    ----------
    path : string file path, or file-like object
    columns : sequence, default None
        If not provided, all columns are read

        .. versionadded 0.24.0
    nthreads : int, default 1
        Number of CPU threads to use when reading to pandas.DataFrame

       .. versionadded 0.21.0
       .. deprecated 0.24.0
    use_threads : bool, default True
        Whether to parallelize reading using multiple threads

       .. versionadded 0.24.0

    Returns
    -------
    type of object stored in file

    """

    feather, pyarrow = _try_import()
    path = _stringify_path(path)

    if LooseVersion(pyarrow.__version__) < LooseVersion('0.11.0'):
        int_use_threads = int(use_threads)
        if int_use_threads < 1:
            int_use_threads = 1
        return feather.read_feather(path, columns=columns,
                                    nthreads=int_use_threads)

    return feather.read_feather(path, columns=columns,
                                use_threads=bool(use_threads)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:43,代码来源:feather_format.py

示例8: test_stringify_path_pathlib

# 需要导入模块: from pandas.io import common [as 别名]
# 或者: from pandas.io.common import _stringify_path [as 别名]
def test_stringify_path_pathlib(self):
        rel_path = common._stringify_path(Path('.'))
        assert rel_path == '.'
        redundant_path = common._stringify_path(Path('foo//bar'))
        assert redundant_path == os.path.join('foo', 'bar') 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:7,代码来源:test_common.py

示例9: test_stringify_path_localpath

# 需要导入模块: from pandas.io import common [as 别名]
# 或者: from pandas.io.common import _stringify_path [as 别名]
def test_stringify_path_localpath(self):
        path = os.path.join('foo', 'bar')
        abs_path = os.path.abspath(path)
        lpath = LocalPath(path)
        assert common._stringify_path(lpath) == abs_path 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:7,代码来源:test_common.py

示例10: test_stringify_path_fspath

# 需要导入模块: from pandas.io import common [as 别名]
# 或者: from pandas.io.common import _stringify_path [as 别名]
def test_stringify_path_fspath(self):
        p = CustomFSPath('foo/bar.csv')
        result = common._stringify_path(p)
        assert result == 'foo/bar.csv' 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:6,代码来源:test_common.py

示例11: read_feather

# 需要导入模块: from pandas.io import common [as 别名]
# 或者: from pandas.io.common import _stringify_path [as 别名]
def read_feather(path, nthreads=1):
    """
    Load a feather-format object from the file path

    .. versionadded 0.20.0

    Parameters
    ----------
    path : string file path, or file-like object
    nthreads : int, default 1
        Number of CPU threads to use when reading to pandas.DataFrame

       .. versionadded 0.21.0

    Returns
    -------
    type of object stored in file

    """

    feather = _try_import()
    path = _stringify_path(path)

    if LooseVersion(feather.__version__) < LooseVersion('0.4.0'):
        return feather.read_dataframe(path)

    return feather.read_dataframe(path, nthreads=nthreads) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:29,代码来源:feather_format.py

示例12: __init__

# 需要导入模块: from pandas.io import common [as 别名]
# 或者: from pandas.io.common import _stringify_path [as 别名]
def __init__(self, path, mode=None, complevel=None, complib=None,
                 fletcher32=False, **kwargs):
        try:
            import tables  # noqa
        except ImportError as ex:  # pragma: no cover
            raise ImportError('HDFStore requires PyTables, "{ex}" problem '
                              'importing'.format(ex=str(ex)))

        if complib is not None and complib not in tables.filters.all_complibs:
            raise ValueError(
                "complib only supports {libs} compression.".format(
                    libs=tables.filters.all_complibs))

        if complib is None and complevel is not None:
            complib = tables.filters.default_complib

        self._path = _stringify_path(path)
        if mode is None:
            mode = 'a'
        self._mode = mode
        self._handle = None
        self._complevel = complevel if complevel else 0
        self._complib = complib
        self._fletcher32 = fletcher32
        self._filters = None
        self.open(mode=mode, **kwargs) 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:28,代码来源:pytables.py

示例13: read_feather

# 需要导入模块: from pandas.io import common [as 别名]
# 或者: from pandas.io.common import _stringify_path [as 别名]
def read_feather(path, nthreads=1):
    """
    Load a feather-format object from the file path

    .. versionadded 0.20.0

    Parameters
    ----------
    path : string file path, or file-like object
    nthreads : int, default 1
        Number of CPU threads to use when reading to pandas.DataFrame

       .. versionadded 0.21.0

    Returns
    -------
    type of object stored in file

    """

    feather = _try_import()
    path = _stringify_path(path)

    if feather.__version__ < LooseVersion('0.4.0'):
        return feather.read_dataframe(path)

    return feather.read_dataframe(path, nthreads=nthreads) 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:29,代码来源:feather_format.py

示例14: test_stringify_path_pathlib

# 需要导入模块: from pandas.io import common [as 别名]
# 或者: from pandas.io.common import _stringify_path [as 别名]
def test_stringify_path_pathlib(self):
        tm._skip_if_no_pathlib()

        rel_path = common._stringify_path(Path('.'))
        assert rel_path == '.'
        redundant_path = common._stringify_path(Path('foo//bar'))
        assert redundant_path == os.path.join('foo', 'bar') 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:9,代码来源:test_common.py

示例15: test_stringify_path_localpath

# 需要导入模块: from pandas.io import common [as 别名]
# 或者: from pandas.io.common import _stringify_path [as 别名]
def test_stringify_path_localpath(self):
        tm._skip_if_no_localpath()

        path = os.path.join('foo', 'bar')
        abs_path = os.path.abspath(path)
        lpath = LocalPath(path)
        assert common._stringify_path(lpath) == abs_path 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:9,代码来源:test_common.py


注:本文中的pandas.io.common._stringify_path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。