當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。