Python Application(Pandas (data manipulation) and Matplotlib (trending))_with Data format issues


Python Application(Pandas (data manipulation) and Matplotlib (trending))_with Data format issues

Presenting by formats as CSV,XLSX or HTML of conclusions on some mathematical operations with importing by CSV or XLSX formats of some raw sensor data also plotting to this conclusions(including to carrying-out into same folder of all application conclusions as a whole )   


xlsx data as example;


  

or you can use to similarly csv data.(Note:a input problem for CSV format is not subject.But,for XLSX format input requires xlrd module(pip install xlrd method).

For example,We are producing to a file as data_with_headers.xlsx  into a folder at desktop.And next,preparing to Python program;
   


# import Pandas (data manipulation) and Matplotlib (trending)
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

# load the data file
data_file = pd.read_excel('data_with_headers.xlsx')
print(data_file[0:3])

time=data_file['time']
sensors=data_file.ix[:,'s1':'s4']
print(sensors[0:6])


time=time-time[0]
print(time[0:3])


avg_row=np.mean(sensors,1)
avg_col=np.mean(sensors,0)
print(avg_row[0:3])
print(avg_col)


my_data=[time,sensors,avg_row]
result=pd.concat(my_data,axis=1)
print(result[0:3])


result.to_csv('result.csv')
result.to_excel('result.xlsx')
result.to_html('result.htm')
result.to_clipboard()


plt.figure(1)
plt.plot(time,sensors['s1'],'r-')
plt.plot(time,avg_row,'b.')
plt.legend(['sensor 1','Average'])
plt.xlabel('time (sec)')
plt.ylabel('sensor values')
plt.savefig('myplot.png')
plt.show()

            

You have to files as three result and one myplot  by Python Compilation 

Result files;






And,Myplot;






Other Note:openpyxl module for output as xlsx format of Conclusion is requiring(via pip install openpyxl method)


Numeric Conclusions:











Yorumlar

Bu blogdaki popüler yayınlar

Important Tectonic Components of Turkey Geography based on Anatolian Plate

Informations about experimental plate structures

Obspy-about Developments