Uploaded by Allegra Maddalena Zago

Report, Zago Allegra Maddalena, 900501

advertisement
Zago Allegra Maddalena
900501
REPORT OF THE PYTHON PROJECT
‘FIND AN AIRBNB IN SAN FRANCISCO BASED ON THE DATASET GIVEN’
The following report will analyze the PYTHON SCRIPT I produced, which has the
aim of efficiently finding and extracting the URL of an Airbnb in San Francisco b y
getting the information from a dataset that contains more than 6000 links to Airbnbs.
This specific script applies well defined criteria, in order to filter from the whole
amount of URLs just the one that follows all of our requirements; these
characteristics are contained in a dataset, that I renamed “dataset.csv”, which was
saved in my desktop along with the script.
First of all, I imported the Pandas Library, which will read the dataset that I was given
into a dataframe that I renamed “dati”, in order for me to remember that that specific
data frame contained all the data that I had to use later on. After that, I gave the
input to print all my “dati”.
Secondly, I created a subset of the dataset, called “group1”, that is based on all the
conditions that the professor asked us to take into consideration, like the number of
beds, bathrooms and bedrooms, along with the price that had to be lower than 250$,
and the reviews of both scores in rating and location.
Right after that, I created a second subset of the dataset that I similarly named
“group2”, that instead was based on the conditions of longitude being less than
-122,49.
I then proceeded to give the input to print both groups.
Then I created a list of URLs, given by the merge of the two sets I analyzed, using
an inner join, that would merge the groups I created before based on the “listing_url”
column.
By doing that, the program was able to check if the resulting merging dataset was
empty or not: if the first option occurred, “False” would have been printed, while if the
second one did, all the possible URLs would have been printed.
Given the conditions I had, only one URL was printed:
https://www.airbnb.com/rooms/14705126
The resulting Airbnb follows exactly the conditions I was given, having exactly 2
bedrooms, 3 beds (one of them is a sofa/bed), more than one bathroom, along with
the reviews that are perfectly respected.
Thanks to the Python script, I was able to sort and find the common lists that satisfy
the criteria in both sets; only one URL resulted from the console and since it follows
every condition I previously imposed, I decided to pick the previously linked Airbnb.
Download