Reputation: 6592
I am reading data from a text file and then I do a sort of random walk among the rows. How would you mark a row as "read"?
This is how I'm reading the data:
import pandas as pd
set = pd.read_csv('file.txt', sep=" ", header = None)
set.columns = ["A", "B", "C", "D", "E", "F", "G"]`
Upvotes: 1
Views: 659
Reputation: 6592
To add a column: data.insert(8, "flag", 0)
. 0 can be changed to 1 or other values later in the code
Upvotes: 0
Reputation: 2917
Shuffle the dataframe with numpy using the technique in this question, then iterate over the rows.
so:
df = pd.read_csv('file.txt', sep=" ", header = None)
df.columns = columns = ["A", "B", "C", "D", "E", "F", "G"]
df = df.apply(numpy.random.permutation)
for row in df.iterrows():
#process row here
Upvotes: 3