Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started