Python pandas.read_clipboard() Examples

The following are 25 code examples of pandas.read_clipboard(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pandas , or try the search function .
Example #1
Source File: namespace.py    From koalas with Apache License 2.0 6 votes vote down vote up
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)) 
Example #2
Source File: test_clipboard.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
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 
Example #3
Source File: power_curve.py    From PCWG with MIT License 5 votes vote down vote up
def parse_clipboard(self):
            
            clip_board_df = pd.read_clipboard()
            
            if clip_board_df is None:
                return
                
            if len(clip_board_df.columns) < 2:
                return 
                
            for index in clip_board_df.index:
                self.add_clip_board_row(clip_board_df.ix[index])

            self.validatedPowerCurveLevels.validate() 
Example #4
Source File: test_io.py    From modin with Apache License 2.0 5 votes vote down vote up
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) 
Example #5
Source File: test_io.py    From modin with Apache License 2.0 5 votes vote down vote up
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) 
Example #6
Source File: io.py    From modin with Apache License 2.0 5 votes vote down vote up
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)) 
Example #7
Source File: test_clipboard.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
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') 
Example #8
Source File: test_clipboard.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #9
Source File: test_clipboard.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #10
Source File: pyspc_remi.py    From pyspc with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #11
Source File: test_clipboard.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
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') 
Example #12
Source File: test_clipboard.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
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) 
Example #13
Source File: test_clipboard.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
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 
Example #14
Source File: test_clipboard.py    From recruit with Apache License 2.0 5 votes vote down vote up
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 
Example #15
Source File: test_clipboard.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
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 
Example #16
Source File: test_clipboard.py    From Computable with MIT License 5 votes vote down vote up
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) 
Example #17
Source File: test_clipboard.py    From vnpy_crypto with MIT License 5 votes vote down vote up
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') 
Example #18
Source File: test_clipboard.py    From vnpy_crypto with MIT License 5 votes vote down vote up
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) 
Example #19
Source File: test_clipboard.py    From vnpy_crypto with MIT License 5 votes vote down vote up
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 
Example #20
Source File: test_clipboard.py    From vnpy_crypto with MIT License 5 votes vote down vote up
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 
Example #21
Source File: test_clipboard.py    From vnpy_crypto with MIT License 5 votes vote down vote up
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 
Example #22
Source File: test_clipboard.py    From recruit with Apache License 2.0 5 votes vote down vote up
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') 
Example #23
Source File: test_clipboard.py    From recruit with Apache License 2.0 5 votes vote down vote up
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) 
Example #24
Source File: test_clipboard.py    From recruit with Apache License 2.0 5 votes vote down vote up
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 
Example #25
Source File: test_clipboard.py    From recruit with Apache License 2.0 5 votes vote down vote up
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