Both versions of the code are working. I am trying to understand the difference between self.data_as_csv vs data_as_csv.
In which scenario each of them is useful over the another.
Version 1:
import pandas as pd
class test_class:
def __init__(self, inputFile):
self.file = inputFile
def generate_csv(self):
self.data_as_csv = pd.read_csv(self.file)
return self.data_as_csv
x = test_class("out.csv")
df = x.generate_csv()
print(df)
Version 2:
import pandas as pd
class test_class:
def __init__(self, inputFile):
self.file = inputFile
def generate_csv(self):
data_as_csv = pd.read_csv(self.file)
return data_as_csv
x = test_class("out.csv")
df = x.generate_csv()
print(df)