#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jun 21 14:29:57 2023 @author: richardson """ import numpy as np a = [1,2,7,-2,2,3,0,0,1] na = np.array(a) # makes the list into numpy array aM = na.reshape(3,3)# makes 3x3 array (i.e. matrix) # print(aM) # print(aM.T) # transpose # print(2*aM+3) # does 2x+3 to each element of the array # print(aM*aM) # multiplies entry by entry - not matrix mult # print(np.dot(aM,aM)) # actual matrix mult # print(np.dot(na,na)) # dot product of vectors # print(np.trace(aM)) from numpy import linalg as LA # print(LA.det(aM)) # print(LA.inv(aM)) # inverse # print(LA.eigvals(aM)) # print((3+4j)*(2-1j)) # python uses eg 1j for i, 2j for 2i, etc. import scipy from scipy import linalg as LA2 # print(np.exp(aM)) # does e^x to all entries of the matrix # print(LA.exp(aM)) no matrix exp in linalg inside numpy # print(LA2.expm(aM)) # matrix exponential # other scipy stuff from scipy import integrate as IN def ff(x): return np.exp(-x*x) # print(ff(-1)) # print(ff(0)) # print(ff(1)) # print(ff(2)) # print(IN.quad(ff,0,4)) # tuple # # first entry is the approx value of the integral # # second entry is the abs error estimate in the value. # print(IN.quad(ff,0,4)[0]) # print(IN.quad(ff,0,np.inf)) # print(np.sqrt(np.pi)/2) #### # pandas is a statistical data package # does most things R can do import pandas as pd import numpy as np WS = pd.read_csv('sampleData.csv', header=None) bubba = np.array(WS) # makes data into np array bubba2 = WS.values.tolist() # makes it into a list print(bubba) print(bubba2) newData = np.reshape(bubba,(4,6)) df = pd.DataFrame(newData) filenm = "other.xlsx" df.to_excel(excel_writer = filenm,sheet_name="Data",header=None,index=None) df.to_csv("other.csv",header=None,index=None)