Python for Data Analys
After discussing SQL a bit and how to run it, I will next explain Python from what I have learned in this bootcamp.
What is Python?
Python is a programming language used to create applications, computer commands, and vehicle analysis. According to the TIOBE Index for 2022, Python is becoming the most popular programming language. The easy-to-read and efficient syntax makes Python easy to learn, especially for beginners. Python has a toolbox that helps process data analysis, statistical calculations, mathematics, and machine learning with a broad community ecosystem. Python can be run in a variety of ways, including through the free Google Collaborate platform.
How to run Python
Question 1
Create a function with:
- 1 argument in the form of a dataframe to check the data type,
- to check the number of null values,
- to check the percent null value,
- and the number of unique values of each column in a dataframe
Question 2
How many visitors are there who cancel reservations and who don’t? And from these numbers make inferences about the proportions of each!
Because the data you want to display is the number of reservation cancellations, the source data is is_cancelled with the value_counts function. 0 = False while 1=true, so the number of visitors who canceled the reservation was 44,224 people. To display the proportion, a bar chart is used
Question 3
A. For “City Hotel”, what percentage of reservations are cancelled?
B. For “Resort Hotel”, what percentage of reservations are cancelled?
To get the percent value of the value_counts function multiplied by 100. The round function is used to round a number. ,1 is used for the number of numbers after the period
Question 4
Perform a filter so that it only shows visitor data that didn’t cancel a reservation. And store the result in a df_checkout variable.
The filter to show visitors who didn’t cancel a reservation is stored in a df_checkout variable so that the dataframe we’ll be using is df_checkout. Visitors not canceling a reservation means is_canceled=0
Question 5
A. Show the number of reservations per month of arrival for each hotel type.
B. Then in what month are there the most reservations in each type of hotel? Make a conclusion whether the trend is the same in both types of hotels?
Question 6
A. Create a new column named arrival_date that contains complete info about the year, month, and date of arrival.
B. Change the column to a datetime type.
Question 7
Let’s play with time-series data using arrival_date columns. Create 2 dataframes that show as follows:
1. Daily total reservations (df_reservasi_perhari)
2. Average daily reservations per week (df_avg_reservasi_harian)
Question 8
A. What is the average ADR based on hotel type and customer type (customer_type)?
B. Which type of customer has the largest ADR in each type of hotel?
Data is combined based on hotel type and customer type so that groupby function is used. Unlike SQL or Excel, the average function in Python is the mean.
Get Helena Paulina’s stories in your inbox
Join Medium for free to get updates from this writer.
That’s all about Python. Next I’ll cover data visualization using Google Data Studio.







