Skip to content

Instantly share code, notes, and snippets.

@cpascual
Last active August 21, 2017 08:22
Show Gist options
  • Save cpascual/4d44c3307aa4ed707ce3afa234e8b428 to your computer and use it in GitHub Desktop.
Save cpascual/4d44c3307aa4ed707ce3afa234e8b428 to your computer and use it in GitHub Desktop.
A simple example of using taurus eval scheme with pandas to read a column of a CSV data file
"""
A simple example of using taurus eval scheme with pandas to
read a column of a CSV data file
"""
#create a dummy csv file with 2 columns with headers "x" and "y"
data=\
'''
x,y
2,4
3,6
4,8
5,10
'''
with open('foo.csv', 'w') as f:
f.write(data)
# read column "y" from foo.csv file as a taurus attribute using pandas
import taurus
m = "eval:@pandas.*/read_csv('foo.csv')['y'].as_matrix()"
a = taurus.Attribute(m)
print a.read()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment