Skip to content Skip to sidebar Skip to footer

Python Translation Of R's Read.table 'text' Argument

In R if someone on SO posts a data frame as text: x y 1 1 a 2 2 b 3 3 c One would highlight and copy the data frame as is, and paste it into R to recreate it: df <- read.tab

Solution 1:

As @EdChurn suggested in the comments, the task is very simple and straightforward with pandas:

  1. Copy the data from the original source with Ctrl+C (or other method)

  2. In Python:

    import pandas as pd
    df = pd.read_clipboard()
    >>> df
    
       x  y
    11  a
    22  b
    33  c
    

Post a Comment for "Python Translation Of R's Read.table 'text' Argument"