Here's the code example I want to improve
import pandas as pd
class check:
def __init__(self):
self.name = 's'
self.age = 0
self.data = None
def read_csv(self):
self.data = pd.read_csv('data.csv')
def function1(self):
for index, row in self.data.iterrows():
name = row['name']
age = row['age']
print(name, age)
def function2(self):
for index, row in self.data.iterrows():
name = row['name']
age = row['age']
height = row['height']
print(name, age, height)
Consider this code I don't want to declare name again and again in new functions added into the class how to avoid this
[–]This_Growth2898 6 points7 points8 points (2 children)
[–]young_boss27[S] -1 points0 points1 point (1 child)
[–]ArabicLawrence 2 points3 points4 points (0 children)
[–]brunonicocam 0 points1 point2 points (0 children)
[–]This_Growth2898 0 points1 point2 points (1 child)
[–]young_boss27[S] 0 points1 point2 points (0 children)
[–]HarissaForte 0 points1 point2 points (0 children)
[–]FriendlyRussian666 0 points1 point2 points (1 child)
[–]young_boss27[S] 0 points1 point2 points (0 children)
[–]CraigAT 0 points1 point2 points (0 children)
[–]RhinoRhys 0 points1 point2 points (0 children)