Skip to content

Instantly share code, notes, and snippets.

@milo0
Created December 3, 2017 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milo0/94bc50e4de48d4a6d1b7b696fb319e75 to your computer and use it in GitHub Desktop.
Save milo0/94bc50e4de48d4a6d1b7b696fb319e75 to your computer and use it in GitHub Desktop.
Convert tables posted on StackOverflow to pandas DataFrames
import pandas as pd
with open('table.txt') as f:
content = f.readlines()
columns = content.pop(0)
content_list = [row.split() for row in content]
df = pd.DataFrame(columns=columns, data=content_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment