I would like to apply two separate graphs to each text file in a folder with subdirectories, however I wouldn't want them to be joined into one data frame. I am currently only able to load one file into pandas at a time. If I put the root directory, I get an error that the File doesn't exist.
data = pd.read_csv(r'/Users/work/DexterStudio/DataFolder/*', sep=" ", header = None, na_values='NaN')
# organize data
data.drop(data.columns[[4]], axis=1, inplace=True)
data.columns = ["timestamp", "x", "y", "z"]
#get current axes object
frame1 = plt.gca()
#draw two graphs
plt.plot(data['timestamp'],data['x'],color='r', label='x-axis')
plt.plot(data['timestamp'],data['y'], color='b', label='y-axis')
# hide axes
frame1.axes.get_xaxis().set_visible(False)
plt.legend(loc='upper right')
plt.show()
plt.plot(data['timestamp'],data['z'],color='g', label='z-axis')
plt.legend(loc='upper right')
plt.show()
Just do two read statements into two variables and go from there:
data1 = pd.read_csv(r'/Users/work/DexterStudio/DataFolder/file1', sep=" ", header = None, na_values='NaN')
data2 = pd.read_csv(r'/Users/work/DexterStudio/DataFolder/file2', sep=" ", header = None, na_values='NaN')
Note naming the files in the read statement and that you now have data1 and data2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.