The purpose of this script is to produce a data frame that is generated through code written in object oriented style.
The problem is the outcome of this script is an empty data frame.
There is no error.
Here is the code:
import pandas as pd
class Dataframe:
def __init__(self):
self.df = pd.DataFrame()
def name(self):
self.df['name'] = ["Hamza", "Carmen"]
return print(self.df['name'])
def age(self):
self.df['age'] = [20, 15]
return self.df['age']
def sex(self):
self.df['sex'] = ["Male", "Female"]
return self.df['sex']
def address(self):
self.df['adress'] = ["Miami", "Seattle"]
return self.df['adress']
def print(self):
return print(self.df)
x = Dataframe()
x.print()