HackatonSmall / modules /plant.py
Crocolil's picture
Upload folder using huggingface_hub
4e9208d verified
Raw
History Blame Contribute Delete
2.51 kB
import pandas as pd
class Plant:
def __init__(self, genus):
self.genus = genus
self.db_path = './data/growth_csv/growth_ds.csv'
self.watering_frequency = self.get_watering_frequency()
self.plant_name = self.get_plant_name()
self.sunlight = self.get_sunlight_requirements()
self.soil_type = self.get_soil_type()
self.fertilization_type = self.get_fertilization_type()
self.last_watered = None # Track the last watered date
def __str__(self):
return f"Plant(genus={self.genus}, plant_name={self.plant_name}, watering_frequency={self.watering_frequency}, sunlight={self.sunlight}, soil_type={self.soil_type}, fertilization_type={self.fertilization_type})"
def get_watering_frequency(self):
# import csv
growth_csv = pd.read_csv(self.db_path)
plant_data = growth_csv[growth_csv['Genus'] == self.genus]
if not plant_data.empty:
return plant_data['Watering'].iloc[0]
return None # Return None if no data found for the genus
def get_plant_name(self):
# import csv
growth_csv = pd.read_csv(self.db_path)
plant_data = growth_csv[growth_csv['Genus'] == self.genus]
if not plant_data.empty:
return plant_data['Plant Name'].iloc[0]
return None # Return None if no data found for the genus
def get_sunlight_requirements(self):
# import csv
growth_csv = pd.read_csv(self.db_path)
plant_data = growth_csv[growth_csv['Genus'] == self.genus]
if not plant_data.empty:
return plant_data['Sunlight'].iloc[0]
return None # Return None if no data found for the genus
def get_soil_type(self):
# import csv
growth_csv = pd.read_csv(self.db_path)
plant_data = growth_csv[growth_csv['Genus'] == self.genus]
if not plant_data.empty:
return plant_data['Soil'].iloc[0]
return None # Return None if no data found for the genus
def get_fertilization_type(self):
# import csv
growth_csv = pd.read_csv(self.db_path)
plant_data = growth_csv[growth_csv['Genus'] == self.genus]
if not plant_data.empty:
return plant_data['Fertilization Type'].iloc[0]
return None # Return None if no data found for the genus
def set_last_watered(self, date):
self.last_watered = date