hi everyone, please I am a beginner in Python, i would like to use "for" loop to load and plot multiple dataframes from different folders on the same graph (as shown in the picture ) , i started to write a script, but i got stuck , please if you can help me with this.
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import os
f= ("40","50","60")
for i in f:
for j in range(6):
pd.read_csv(os.path.join("/Simulation_Results/10km/","res_"f"{i}",f"sim_{str(j).zfill(3)}","velocity.csv"),sep='\s ',header=None)
CodePudding user response:
You need to store the frames. I don't know how you expect to use them, but here's one way:
import pandas as pd
import os
f= ("40","50","60")
storage = {}
for i in f:
for j in range(6):
storage[(i,j)] = pd.read_csv(os.path.join("/Simulation_Results/10km/","res_"f"{i}",f"sim_{str(j).zfill(3)}","velocity.csv"),sep='\\s ',header=None)
That creates a dictionary, where storage[("40",3)]
, for example, will contain one the the dataframes.