Reputation: 47
I have a file birth_life_data.txt with the format as:
Country fertiliy_rate Life_span
India 5.7 52
USA 10.2 70
...
...
I want to store the fertiliy_rate data in the variable X, and life_span similarly in Y as 1-d arrays, to fed as training data in my TF graph.
How do i use pandas to parse this data and store it in the form of a python array?
Upvotes: 1
Views: 108
Reputation: 21
You can use the read_table() function in pandas to read a text file.
df = pd.read_table('birth_life_data.txt', delim_whitespace=True)
You can then use the inbuilt list() function to convert them to python arrays.
X = list(df['Country'])
Y = list(df['Life_span'])
Upvotes: 2