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
- Split a String into columns using regex 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.mad()
- Python | Pandas DataFrame.where()
- Python | Pandas Dataframe.at[ ]
- Python | Pandas dataframe.max()
- Python | Pandas dataframe.mean()
- Python | Pandas dataframe.get()
- Python | Pandas dataframe.div()
- Reindexing in Pandas DataFrame
- Python | Pandas DataFrame.abs()
- Python | Pandas DataFrame.loc
- Python | Pandas dataframe.pow()
- Python | Pandas dataframe.all()
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.