Skip to content

Instantly share code, notes, and snippets.

@MNovak12
Created August 3, 2017 23:54
Show Gist options
  • Save MNovak12/4939fd93431b287b0b163587a433ab09 to your computer and use it in GitHub Desktop.
Save MNovak12/4939fd93431b287b0b163587a433ab09 to your computer and use it in GitHub Desktop.
Create a dictionary from a csv file where the header row is the keys, and the values are the data in a list
import pandas as pd
data = pd.read_csv('test.csv')
all_rows = {}
for row in data:
items = []
for x in data[row]:
if not pd.isnull(x):
items.append(x)
all_rows[row] = items
print all_rows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment