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
- 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
- Add a row at top in pandas DataFrame
- Python | Pandas dataframe.min()
- Python | Pandas dataframe.sum()
- Python | Pandas dataframe.take()
- Python | Pandas dataframe.mod()
- Python | Pandas dataframe.pow()
- Python | Pandas dataframe.std()
- Python | Pandas dataframe.add()
- Python | Pandas dataframe.sem()
- Reindexing in Pandas DataFrame
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.