Skip to content

Instantly share code, notes, and snippets.

View theomitsa's full-sized avatar

Theophano Mitsa theomitsa

View GitHub Profile
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!")
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")
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)
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)
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
@theomitsa
theomitsa / index_select_Python
Created August 1, 2019 04:52
how to select using index in Python
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])
```{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)
```
```{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
```{r}
#Select first row
print(DepositFrame[1,])
#Print first column
print(DepositFrame[,1])
#Print first element
DepositFrame[1,1]
```
```{python}
import numpy as np
```{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