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


Python parsers.read_table方法代码示例

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


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

示例1: check_compressed_urls

# 需要导入模块: from pandas.io import parsers [as 别名]
# 或者: from pandas.io.parsers import read_table [as 别名]
def check_compressed_urls(salaries_table, compression, extension, mode,
                          engine):
    # test reading compressed urls with various engines and
    # extension inference
    base_url = ('https://github.com/pandas-dev/pandas/raw/master/'
                'pandas/tests/io/parser/data/salaries.csv')

    url = base_url + extension

    if mode != 'explicit':
        compression = mode

    url_table = read_table(url, compression=compression, engine=engine)
    tm.assert_frame_equal(url_table, salaries_table) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:16,代码来源:test_network.py

示例2: salaries_table

# 需要导入模块: from pandas.io import parsers [as 别名]
# 或者: from pandas.io.parsers import read_table [as 别名]
def salaries_table(datapath):
    """DataFrame with the salaries dataset"""
    return read_table(datapath('io', 'parser', 'data', 'salaries.csv')) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:5,代码来源:conftest.py

示例3: from_csv

# 需要导入模块: from pandas.io import parsers [as 别名]
# 或者: from pandas.io.parsers import read_table [as 别名]
def from_csv(cls, path, header=0, sep=',', index_col=0,
                 parse_dates=True, encoding=None, tupleize_cols=False,
                 infer_datetime_format=False):
        """
        Read delimited file into DataFrame

        Parameters
        ----------
        path : string file path or file handle / StringIO
        header : int, default 0
            Row to use at header (skip prior rows)
        sep : string, default ','
            Field delimiter
        index_col : int or sequence, default 0
            Column to use for index. If a sequence is given, a MultiIndex
            is used. Different default from read_table
        parse_dates : boolean, default True
            Parse dates. Different default from read_table
        tupleize_cols : boolean, default False
            write multi_index columns as a list of tuples (if True)
            or new (expanded format) if False)
        infer_datetime_format: boolean, default False
            If True and `parse_dates` is True for a column, try to infer the
            datetime format based on the first datetime string. If the format
            can be inferred, there often will be a large parsing speed-up.

        Notes
        -----
        Preferable to use read_table for most general purposes but from_csv
        makes for an easy roundtrip to and from file, especially with a
        DataFrame of time series data

        Returns
        -------
        y : DataFrame
        """
        from pandas.io.parsers import read_table
        return read_table(path, header=header, sep=sep,
                          parse_dates=parse_dates, index_col=index_col,
                          encoding=encoding, tupleize_cols=tupleize_cols,
                          infer_datetime_format=infer_datetime_format) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:43,代码来源:frame.py

示例4: read_clipboard

# 需要导入模块: from pandas.io import parsers [as 别名]
# 或者: from pandas.io.parsers import read_table [as 别名]
def read_clipboard(**kwargs):  # pragma: no cover
    """
    Read text from clipboard and pass to read_table. See read_table for the
    full argument list

    If unspecified, `sep` defaults to '\s+'

    Returns
    -------
    parsed : DataFrame
    """
    if kwargs.get('sep') is None and kwargs.get('delim_whitespace') is None:
        kwargs['sep'] = '\s+'
    from pandas.util.clipboard import clipboard_get
    from pandas.io.parsers import read_table
    text = clipboard_get()

    # try to decode (if needed on PY3)
    if compat.PY3:
        try:
            text = compat.bytes_to_str(
                text, encoding=(kwargs.get('encoding') or
                                get_option('display.encoding'))
            )
        except:
            pass
    return read_table(StringIO(text), **kwargs) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:29,代码来源:clipboard.py

示例5: salaries_table

# 需要导入模块: from pandas.io import parsers [as 别名]
# 或者: from pandas.io.parsers import read_table [as 别名]
def salaries_table():
    path = os.path.join(tm.get_data_path(), 'salaries.csv')
    return read_table(path) 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:5,代码来源:test_network.py

示例6: read_clipboard

# 需要导入模块: from pandas.io import parsers [as 别名]
# 或者: from pandas.io.parsers import read_table [as 别名]
def read_clipboard(sep='\s+', **kwargs):  # pragma: no cover
    r"""
    Read text from clipboard and pass to read_table. See read_table for the
    full argument list

    Parameters
    ----------
    sep : str, default '\s+'.
        A string or regex delimiter. The default of '\s+' denotes
        one or more whitespace characters.

    Returns
    -------
    parsed : DataFrame
    """
    encoding = kwargs.pop('encoding', 'utf-8')

    # only utf-8 is valid for passed value because that's what clipboard
    # supports
    if encoding is not None and encoding.lower().replace('-', '') != 'utf8':
        raise NotImplementedError(
            'reading from clipboard only supports utf-8 encoding')

    from pandas.io.clipboard import clipboard_get
    from pandas.io.parsers import read_table
    text = clipboard_get()

    # try to decode (if needed on PY3)
    # Strange. linux py33 doesn't complain, win py33 does
    if compat.PY3:
        try:
            text = compat.bytes_to_str(
                text, encoding=(kwargs.get('encoding') or
                                get_option('display.encoding'))
            )
        except:
            pass

    # Excel copies into clipboard with \t separation
    # inspect no more then the 10 first lines, if they
    # all contain an equal number (>0) of tabs, infer
    # that this came from excel and set 'sep' accordingly
    lines = text[:10000].split('\n')[:-1][:10]

    # Need to remove leading white space, since read_table
    # accepts:
    #    a  b
    # 0  1  2
    # 1  3  4

    counts = set([x.lstrip().count('\t') for x in lines])
    if len(lines) > 1 and len(counts) == 1 and counts.pop() != 0:
        sep = '\t'

    if sep is None and kwargs.get('delim_whitespace') is None:
        sep = '\s+'

    return read_table(StringIO(text), sep=sep, **kwargs) 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:60,代码来源:clipboards.py


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