We have some data in string format, we will discuss how to load this data into pandas dataframe.
Solution # 1: One way to achieve this is to use the StringIO ()
. It will act as a wrapper and help you read data using the pd.read_csv ()
function.
|
Output:
Like us we see the output, we have successfully read and the data as a string in a Pandas DataFrame.
Solution 2. Another fantastic approach — use pd.read_clipboard ()
pandas pd.read_clipboard ()
.
|
Output:
Here what it looks like after we copy the data to the clipboard.
Now we will use pd.read_clipboard ()
pandas pd.read_clipboard ()
to read data into a DataFrame.
|
Output: