Question: How can I fix this code so that the data given from the Plant _ data excel sheet imports and gives the highest and lowest
How can I fix this code so that the data given from the Plantdata excel sheet imports and gives the highest and lowest correlation. Then, displays the code in a pdf folder and the console? Code is not appearing on console or pdf file
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
def readtovaluesfilepath:
with openfilepath as csvfile:
reader csvDictReadercsvfile
atmtemp
soiltemp
atmhum
soilhum
for row in reader:
atmtemp.appendfloatrowAtmosphere Temp'
soiltemp.appendfloatrowSoil Temperature'
atmhum.appendfloatrowAtmosphere Humidity'
soilhum.appendfloatrowSoil Humidity'
return atmtemp, soiltemp, atmhum, soilhum
def corrcalcatmtemp, soiltemp, atmhum, soilhum:
# Correlation Calculations
correlations atmtemp, soiltemp, atmhum, soilhum.corrmethod'spearman'
# Highest and Lowest Correlations
correlations correlations.unstacksortvaluesascendingFalse
highestpositivecorr correlationscorrelations & correlations index
highestnegativecorr correlationscorrelations index
result correlationshighestpositivecorr
result correlationshighestnegativecorr
printfHighest Positive Correlation: highestpositivecorr Correlation Value: result:f
printfHighest Negative Correlation: highestnegativecorr Correlation Value: result:f
return highestpositivecorr, highestnegativecorr
def plotmedf col col title:
# Plot scatter plots with regression lines
snslmplotxcol ycol datadf
plttitletitle
pltxlabelcol
pltylabelcol
plttightlayout
pltsavefigcontentdriveMyDriveColab NotebooksPlantCorr.pdf
pltshow
def main:
filepath contentdriveMyDriveColab NotebooksPlantDataOGcsv
atmtemp, soiltemp, atmhum, soilhum readtovalues
highestpositivecorr, highestnegativecorr corrcalcatmtemp, soiltemp, atmhum, soilhum
plotmeatmtemp, soiltemp, atmhum, soilhum, highestpositivecorr highestpositivecorr "Highest Positive Correlation"
plotmeatmtemp, soiltemp, atmhum, soilhum, highestnegativecorr highestnegativecorr "Highest Negative Correlation"
if namemain:
main
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
