0
0
Data Analysis Pythondata~10 mins

Log transformation for skewed data in Data Analysis Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the numpy library for log transformation.

Data Analysis Python
import [1] as np
Drag options to blanks, or click blank then click option'
Anumpy
Bpandas
Cmatplotlib
Dseaborn
Attempts:
3 left
💡 Hint
Common Mistakes
Importing pandas instead of numpy
Using matplotlib which is for plotting
Forgetting to import any library
2fill in blank
medium

Complete the code to apply log transformation to the 'Income' column in the DataFrame 'df'.

Data Analysis Python
df['log_income'] = np.[1](df['Income'])
Drag options to blanks, or click blank then click option'
Aexp
Blog
Csqrt
Dmean
Attempts:
3 left
💡 Hint
Common Mistakes
Using square root instead of log
Using exponential function by mistake
Applying mean function which is not a transformation
3fill in blank
hard

Fix the error in the code to avoid log of zero or negative values by adding 1 before log transformation.

Data Analysis Python
df['log_sales'] = np.log(df['Sales'] [1] 1)
Drag options to blanks, or click blank then click option'
A*
B-
C+
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Subtracting 1 which can cause negative values
Multiplying or dividing which changes scale incorrectly
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.

Data Analysis Python
{word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
Bword.upper()
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using word.upper() instead of length
Using less than instead of greater than
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase keys to values only if value is positive.

Data Analysis Python
result = { [1]: [2] for k, v in data.items() if v [3] 0 }
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk
Attempts:
3 left
💡 Hint
Common Mistakes
Using original keys without uppercase
Using wrong comparison operator
Swapping keys and values