I have a text file with five columns. First column has year(2011 to 2040), 2nd has Tmax, 3rd has Tmin, 4th has Precip, and fifth has Solar for 30 years. I would like to write a python code which shuffles the first column (year) 10 times with remaining columns having the corresponding original values in them, that is: I want to shuffle year columns only for 10 times so that year 1 will have the corresponding values.
Share
Read the text as a list of rows, each row being a list or tuple of columns. The
csvmodule may be useful for this.Then just shuffle the rows. The
randommodule has a function calledshuffle.EDIT:
Assuming the input format is CSV (comma separated value):