This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class villa(object): | |
| def __init__(self,n,id): | |
| self.villaName=n | |
| def setPersonalAssistant(self,pa): | |
| self.personalAssistant=pa | |
| print(f"{pa} will be on call from 8.00am to 8.00pm for villa {self.villaName}") | |
| def cleanAndChangeKey(self,d1,d2): | |
| print(f"Villa {self.villaName} will be cleaned and keys will be changed on {d1} and {d2}") | |
| def printGiftLabel(self,s): | |
| print(f"Welcome at the {self.villaName}, {s} party!") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class vipVilla(villa): | |
| def __init__(self,nn,id): | |
| villa.__init__(self,nn,id) | |
| def setPersonalAssistant(self,pa): | |
| self.vipPersAssist=pa | |
| print(f"{pa} will be on call (7.00am-9.00pm) for villa {self.villaName} and arrange for a personal yacht") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class guest(object): | |
| def __init__(self,l1,f1,b,c): | |
| self.first=l1 | |
| self.last=f1 | |
| self.noofAdults=b | |
| self.noofChildren=c | |
| def getLastName(self): | |
| return self.last | |
| def __repr__(self): | |
| return 'Guest: (%s, %s)' % (self.first, self.last) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class resort(object): | |
| vil=['Elektra','Persephone','Artemis','Kouros'] | |
| vipVil=['Zeus','Alexandrian'] | |
| guestList=[] | |
| reservationList=[] | |
| resIDList=[0] | |
| def __init__(self): | |
| print("Welcome to Myconos Hidden Cove!") | |
| def setGuest(self,g): | |
| self.guestList.append(g) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class reservation(object): | |
| def __init__(self,n,de,le): | |
| self.checkinDate=de | |
| self.lengthofStay=le | |
| self.villaName=n | |
| self.checkoutDate=de+datetime.timedelta(days=le) | |
| def getvillaName(self): | |
| return self.villaName | |
| def getcheckinDate(self): | |
| return self.checkinDate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| heart_P=pd.read_csv('heart.csv') | |
| #Select first row. Returns Series. | |
| print(heart_P.iloc[0]) | |
| #Select first row. Returns Dataframe. | |
| print(heart_P.iloc[[0]]) | |
| #Select first column | |
| print(heart_P.iloc[:,0]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ```{r} | |
| heart_R<-read.csv("heart.csv",header=TRUE, fileEncoding="UTF-8-BOM") | |
| ``` | |
| ```{python} | |
| import pandas as pd | |
| heart_P=pd.read_csv('heart.csv') | |
| #read only certain columns from a csv file | |
| drop_cols=['thal','thalach'] | |
| heart_Pr=pd.read_csv('heart.csv',usecols=lambda cc : cc not in drop_cols, index_col=False) | |
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ```{r} | |
| library(tidyverse) | |
| set.seed(3) | |
| mat1<-matrix(rnorm(6,12,3), nrow=2) | |
| dimnames(mat1)=list(c("dep1","dep2"),c("Tom","Jim","Sam")) | |
| DepositFrame=as.data.frame(mat1) | |
| print(DepositFrame) | |
| ```{python} | |
| import numpy as np |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ```{r} | |
| #Select first row | |
| print(DepositFrame[1,]) | |
| #Print first column | |
| print(DepositFrame[,1]) | |
| #Print first element | |
| DepositFrame[1,1] | |
| ``` | |
| ```{python} | |
| import numpy as np |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ```{r} | |
| #selecting a multitude of columns using select() | |
| DepositFrame%>%select("Tom","Sam") | |
| #Filter using a regular expression | |
| DepositFrame%>%select(matches("S.+m"))%>%glimpse() | |
| #Filter based on a logical expression | |
| DepositFrame %>% select(matches("m"))%>% | |
| select_if(~max(.,na.rm=TRUE)<12)%>%glimpse() | |
| #Print the age of men with high cholesterol |
OlderNewer