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


Python pandas.read_clipboard方法代码示例

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


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

示例1: read_clipboard

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import read_clipboard [as 别名]
def read_clipboard(sep=r"\s+", **kwargs):
    r"""
    Read text from clipboard and pass to read_csv. See read_csv 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.

    See Also
    --------
    DataFrame.to_clipboard : Write text out to clipboard.

    Returns
    -------
    parsed : DataFrame
    """
    return from_pandas(pd.read_clipboard(sep, **kwargs)) 
开发者ID:databricks,项目名称:koalas,代码行数:22,代码来源:namespace.py

示例2: check_round_trip_frame

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import read_clipboard [as 别名]
def check_round_trip_frame(self, data, excel=None, sep=None,
                               encoding=None):
        data.to_clipboard(excel=excel, sep=sep, encoding=encoding)
        result = read_clipboard(sep=sep or '\t', index_col=0,
                                encoding=encoding)
        tm.assert_frame_equal(data, result, check_dtype=False)

    # Test that default arguments copy as tab delimited 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:10,代码来源:test_clipboard.py

示例3: test_round_trip_frame_string

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import read_clipboard [as 别名]
def test_round_trip_frame_string(self, df):
        df.to_clipboard(excel=False, sep=None)
        result = read_clipboard()
        assert df.to_string() == result.to_string()
        assert df.shape == result.shape

    # Two character separator is not supported in to_clipboard
    # Test that multi-character separators are not silently passed 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:10,代码来源:test_clipboard.py

示例4: test_clipboard_copy_strings

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import read_clipboard [as 别名]
def test_clipboard_copy_strings(self, sep, excel, df):
        kwargs = build_kwargs(sep, excel)
        df.to_clipboard(**kwargs)
        result = read_clipboard(sep=r'\s+')
        assert result.to_string() == df.to_string()
        assert df.shape == result.shape 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,代码来源:test_clipboard.py

示例5: test_read_clipboard_infer_excel

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import read_clipboard [as 别名]
def test_read_clipboard_infer_excel(self, request,
                                        mock_clipboard):
        # gh-19010: avoid warnings
        clip_kwargs = dict(engine="python")

        text = dedent("""
            John James	Charlie Mingus
            1	2
            4	Harry Carney
            """.strip())
        mock_clipboard[request.node.name] = text
        df = pd.read_clipboard(**clip_kwargs)

        # excel data is parsed correctly
        assert df.iloc[1][1] == 'Harry Carney'

        # having diff tab counts doesn't trigger it
        text = dedent("""
            a\t b
            1  2
            3  4
            """.strip())
        mock_clipboard[request.node.name] = text
        res = pd.read_clipboard(**clip_kwargs)

        text = dedent("""
            a  b
            1  2
            3  4
            """.strip())
        mock_clipboard[request.node.name] = text
        exp = pd.read_clipboard(**clip_kwargs)

        tm.assert_frame_equal(res, exp) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:36,代码来源:test_clipboard.py

示例6: test_invalid_encoding

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import read_clipboard [as 别名]
def test_invalid_encoding(self, df):
        # test case for testing invalid encoding
        with pytest.raises(ValueError):
            df.to_clipboard(encoding='ascii')
        with pytest.raises(NotImplementedError):
            pd.read_clipboard(encoding='ascii') 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,代码来源:test_clipboard.py

示例7: test_read_clipboard_infer_excel

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import read_clipboard [as 别名]
def test_read_clipboard_infer_excel(self):
        # gh-19010: avoid warnings
        clip_kwargs = dict(engine="python")

        text = dedent("""
            John James	Charlie Mingus
            1	2
            4	Harry Carney
            """.strip())
        clipboard_set(text)
        df = pd.read_clipboard(**clip_kwargs)

        # excel data is parsed correctly
        assert df.iloc[1][1] == 'Harry Carney'

        # having diff tab counts doesn't trigger it
        text = dedent("""
            a\t b
            1  2
            3  4
            """.strip())
        clipboard_set(text)
        res = pd.read_clipboard(**clip_kwargs)

        text = dedent("""
            a  b
            1  2
            3  4
            """.strip())
        clipboard_set(text)
        exp = pd.read_clipboard(**clip_kwargs)

        tm.assert_frame_equal(res, exp) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:35,代码来源:test_clipboard.py

示例8: check_round_trip_frame

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import read_clipboard [as 别名]
def check_round_trip_frame(self, data_type, excel=None, sep=None):
        data = self.data[data_type]
        data.to_clipboard(excel=excel, sep=sep)
        if sep is not None:
            result = read_clipboard(sep=sep,index_col=0)
        else:
            result = read_clipboard()
        tm.assert_frame_equal(data, result, check_dtype=False) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:10,代码来源:test_clipboard.py

示例9: open_clipboard_pressed

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import read_clipboard [as 别名]
def open_clipboard_pressed(self):
        try:
            self.data = pd.read_clipboard()

            self.data_table.empty()
            table = [list(self.data.columns)] + [[str(x) for x in row] for row in self.data.values]
            self.data_table.from_2d_matrix(table)
        except Exception as e:
            self.text_message(repr(e))
        pass 
开发者ID:carlosqsilva,项目名称:pyspc,代码行数:12,代码来源:pyspc_remi.py

示例10: check_round_trip_frame

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import read_clipboard [as 别名]
def check_round_trip_frame(self, data_type, excel=None, sep=None,
                               encoding=None):
        data = self.data[data_type]
        data.to_clipboard(excel=excel, sep=sep, encoding=encoding)
        if sep is not None:
            result = read_clipboard(sep=sep, index_col=0, encoding=encoding)
        else:
            result = read_clipboard(encoding=encoding)
        tm.assert_frame_equal(data, result, check_dtype=False) 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:11,代码来源:test_clipboard.py

示例11: test_read_clipboard_infer_excel

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import read_clipboard [as 别名]
def test_read_clipboard_infer_excel(self):

        text = dedent("""
            John James	Charlie Mingus
            1	2
            4	Harry Carney
            """.strip())
        clipboard_set(text)
        df = pd.read_clipboard()

        # excel data is parsed correctly
        assert df.iloc[1][1] == 'Harry Carney'

        # having diff tab counts doesn't trigger it
        text = dedent("""
            a\t b
            1  2
            3  4
            """.strip())
        clipboard_set(text)
        res = pd.read_clipboard()

        text = dedent("""
            a  b
            1  2
            3  4
            """.strip())
        clipboard_set(text)
        exp = pd.read_clipboard()

        tm.assert_frame_equal(res, exp) 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:33,代码来源:test_clipboard.py

示例12: test_invalid_encoding

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import read_clipboard [as 别名]
def test_invalid_encoding(self):
        # test case for testing invalid encoding
        data = self.data['string']
        with pytest.raises(ValueError):
            data.to_clipboard(encoding='ascii')
        with pytest.raises(NotImplementedError):
            pd.read_clipboard(encoding='ascii') 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:9,代码来源:test_clipboard.py

示例13: read_clipboard

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import read_clipboard [as 别名]
def read_clipboard(cls, sep=r"\s+", **kwargs):  # pragma: no cover
        ErrorMessage.default_to_pandas("`read_clipboard`")
        return cls.from_pandas(pandas.read_clipboard(sep=sep, **kwargs)) 
开发者ID:modin-project,项目名称:modin,代码行数:5,代码来源:io.py

示例14: test_from_clipboard

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import read_clipboard [as 别名]
def test_from_clipboard():
    setup_clipboard(SMALL_ROW_SIZE)

    pandas_df = pandas.read_clipboard()
    modin_df = pd.read_clipboard()

    df_equals(modin_df, pandas_df) 
开发者ID:modin-project,项目名称:modin,代码行数:9,代码来源:test_io.py

示例15: test_to_clipboard

# 需要导入模块: import pandas [as 别名]
# 或者: from pandas import read_clipboard [as 别名]
def test_to_clipboard():
    modin_df = create_test_modin_dataframe()
    pandas_df = create_test_pandas_dataframe()

    modin_df.to_clipboard()
    modin_as_clip = pandas.read_clipboard()

    pandas_df.to_clipboard()
    pandas_as_clip = pandas.read_clipboard()

    assert modin_as_clip.equals(pandas_as_clip) 
开发者ID:modin-project,项目名称:modin,代码行数:13,代码来源:test_io.py


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