Please see the code below, when running I get a not defined name error for path_to and file_name variable. I guess Python can't access those variable when creating the class instance, what's the logic behind it and how do I fix it?
Thanks!
import os
from dataclasses import dataclass
import pandas as pd
def main():
df = TransactionData(file_name="transactions.xlsx", path_to="./sources")
@dataclass
class TransactionData:
file_name: str
path_to: str
data: pd.DataFrame = pd.read_excel(os.path.join(path_to, file_name))
if __name__ == "__main__":
main