Python study

less than 1 minute read

Published:

Just some adopt scripts or commands.

Outline

  1. Pandas + matplotlib.pyplot

     import pandas as pd
     import matplotlib.pyplot as plt
    
     path = "D:\\Downloads\\"
     filename = "energy.dat"
     separator = "  "
     plot_target = {"data1", "data2", "data3"}
    
     df = pd.read_csv(path + filename, sep = separator, engine='python')
     display(df.head())
    
     plt.figure()
     #for y in df.columns[1:-1]:
     for y in plot_target:    
         plt.semilogy(df["time"], df[y], label=y)
     plt.legend()
     plt.grid()
     plt.show()