String-To-Dataframe
Sat 17 May 2025
title: "String to Dataframe" author: "Rj" date: 2019-04-22 description: "-" type: technical_note draft: false
import numpy as np
import pandas as pd
from io import StringIO
content = """
1, 2
3, 4
5, 6
"""
content
'\n 1, 2\n 3, 4\n 5, 6\n'
df = pd.read_csv(StringIO(content), header=None)
df
| 0 | 1 | |
|---|---|---|
| 0 | 1 | 2 |
| 1 | 3 | 4 |
| 2 | 5 | 6 |
df.shape
(3, 2)
df.describe()
| 0 | 1 | |
|---|---|---|
| count | 3.0 | 3.0 |
| mean | 3.0 | 4.0 |
| std | 2.0 | 2.0 |
| min | 1.0 | 2.0 |
| 25% | 2.0 | 3.0 |
| 50% | 3.0 | 4.0 |
| 75% | 4.0 | 5.0 |
| max | 5.0 | 6.0 |
Score: 5
Category: data-wrangling