1/21
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
when should you use pd.to_datetime() instead of astype(‘datetime64’) ?
when you need to specify date formats or handle errors
1 line code — to drop the column named “ID” from DataFrame df.
df.drop(['ID'])1 line code — to remove all dollar signs ($) from the “Price” columnin DataFrame df.
df['Price'] = df['Price'].str.replace('$', '', regex=False)when would you use df.info() instead of df.head() ?
to check data types and missing value counts
which pandas function converts a string column to datetime format ?
pd.to_datetime()in df.describe() , what does the “25%” row represents?
First Quartile (Q1)
what will be the output of this code?
first = “Data”
second = “Analytics”
print(first + “ ” + second)
Data Analytics
what does df[“Age”].astype(str) do?
converts Age column to string type
what is the data type of the following variable ? age = 25
int
what will be the output of the code?
total = 0
for i range(1, 4):
total += i
print(total)
6
what will be the output of this code?
fruits = [“apple”, “banana”, “cherry”]
print(len(fruits))
3
if df.shape returns (500, 8), what does this mean?
500 rows and 8 columns
1 line code — to count the total number of missing values across ALL columns in DataFrame df.
df.isnull().sum()1 line code — write a list comprehension that creates a new list containing squares of numbers from this list:
numbers = [1, 2, 3, 4, 5]
squares = [n**2 for n in numbers]what does df[“Age”].fillna(0) do?
replaces missing values in Age column with 0
which pandas method removes rows with missing values?
df.dropna()
1 line code — using pandas, count the number of missing values in ALL columns. Assume the data is loaded and the DataFrame name is hdb.
Expected Output: Returns a Series (missing values per column)
hdb.isnull().sum()A Singapore bank wants to reduce customer loan defaults. They have 5 years of loan data including: customer credit score, loan amount, employment status, monthly income, loan duration, and whether the customer defaulted (yes/no).
They want to identify which customers are LIKELY TO DEFAULT in the next 30 days so the bank can contact them early with payment assistance.
What type of analytics problem is this: "identify customers likely to default in next 30 days so bank can intervene early"?
predictive (forecasting who will default)