Mar-27-2023, 03:44 PM
]Can you describe what you mean by this:
Quote:Can someone help me make a class for that as screenshots?I might understand what you mean with goldensample. You are wondering what to do if this is an empty dataframe.
1)More parameter checking only copy a class.
2)when check file without goldensample how to handle this issue.
df = pd.read_csv(csv_add, header=2) df = df[df["Lot Code"].str.contains("golden")]I would have the readcsv() function return None if is no golden data in the file.
import pandas as pd def read_csv(): df = pd.DataFrame( {"Lot Code": ["G", "B", "G"], "Numbers": [5, 6, 7], "Letters": ["A", "B", "C"]} ) df = df[df["Lot Code"].str.contains("G")] if len(df) == 0: return None return df["Numbers"].values, df["Letters"].values x = read_csv() if x is None: sg.popup("Error", "There's no golden data!") else: numbers, letters = x print(numbers, letters)