Skip to content

Instantly share code, notes, and snippets.

@davidandrzej
Created July 11, 2014 15:16
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 davidandrzej/61cca2781675a9a8a4f9 to your computer and use it in GitHub Desktop.
Save davidandrzej/61cca2781675a9a8a4f9 to your computer and use it in GitHub Desktop.
Use Python Pandas to append cycling tags to rows in a CSV file
import pandas as pd
import itertools
# Tag every row in a CSV with repeating 3 tags
df = pd.read_csv('source.csv')
tags = ['foo','baz','buzz']
df['tag'] = [tag for (tag, row) in zip(itertools.cycle(people), df['targetcolumn'])]
df.to_csv('destination.csv')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment