import pandas as pd
import numpy as np
import os

# ======== Configuration Section ========
# Note: Please update the file_path to your local directory before running
file_path = r"G:\FUI\Global_Lake_Water_Color_Time_Series_2000_2018.csv"  # Raw data path
output_dir = r"G:\Test\Shuffled_FUI_Data"  # Output directory
n_shuffles = 1000  # Number of shuffles
# =========================

# Create output directory
os.makedirs(output_dir, exist_ok=True)

# Read raw data (assuming the first column is the index)
df = pd.read_csv(file_path, index_col=0)

# Shuffle data and save
for i in range(1, n_shuffles + 1):
    shuffled_df = pd.DataFrame(index=df.index, columns=df.columns)

    # Shuffle each column independently
    for col in df.columns:
        shuffled_df[col] = np.random.permutation(df[col].values)

    # Save
    output_file = os.path.join(output_dir, f"Lake_FUI_shuffle_{i}.csv")
    shuffled_df.to_csv(output_file, index=True)

print(f"✅ Completed {n_shuffles} shuffles. Files saved in: {output_dir}")