As we know that data comes in all shapes and sizes. They often come from various different sources having different formats. For an aspiring data scientist, it is very important that they know their way around data i.e. loading and storing data present in various formats.
We have some data present in string format, discuss ways to load that data into pandas dataframe.
Solution #1: One way to achieve this is by using the
StringIO() function. It will act as a wrapper and it will help use read the data using the
As we can see in the output, we have successfully read the given data in string format into a Pandas DataFrame.
Solution 2 : Another fantastic approach is to use the pandas
This is what it looks like after we copy the data to clipboard.
Now we will use pandas
pd.read_clipboard() function to read the data into a DataFrame
- Clean the string data in the given Pandas Dataframe
- How to Check the Data Type in Pandas DataFrame?
- Change Data Type for one or more columns in Pandas Dataframe
- String manipulations in Pandas DataFrame
- How to Convert String to Integer in Pandas DataFrame?
- Split a String into columns using regex in pandas DataFrame
- Check if a column starts with given string in Pandas DataFrame?
- Convert the column type from string to datetime format in Pandas dataframe
- Python | Pandas DataFrame.fillna() to replace Null values in dataframe
- Pandas Dataframe.to_numpy() - Convert dataframe to Numpy array
- Add a row at top in pandas DataFrame
- Python | Pandas dataframe.max()
- Reindexing in Pandas DataFrame
- Python | Pandas dataframe.mod()
- How to Sort Pandas DataFrame?
- Python | Pandas dataframe.cov()
- Python | Pandas dataframe.ne()
- Python | Pandas DataFrame.loc
- How to add one row in an existing Pandas DataFrame?
- Python | Pandas DataFrame.ix[ ]
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.