I am loading a txt file containig a mix of float and string data. I want to store them in an array where I can access each element. Now I am just doing
import pandas as pd
data = pd.read_csv('output_list.txt', header = None)
1 0 2000.0 70.2836942112 1347.28369421 /file_address.txt
You can use:
data = pd.read_csv('output_list.txt', sep=" ", header = None) data.columns = ["a", "b", "c", "etc."]
Add sep=" " in your code and leave a blank space between the quotes. So pandas can detect spaces beetween values and sort in columns. Data columns is for naming your columns.