0
0
Data Analysis Pythondata~10 mins

Reproducible analysis patterns 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 pandas library with its common alias.

Data Analysis Python
import [1] as pd
Drag options to blanks, or click blank then click option'
Anumpy
Bpandas
Cmatplotlib
Dseaborn
Attempts:
3 left
💡 Hint
Common Mistakes
Using numpy instead of pandas
Forgetting the alias 'as pd'
Importing visualization libraries instead
2fill in blank
medium

Complete the code to read a CSV file named 'data.csv' into a DataFrame.

Data Analysis Python
df = pd.[1]('data.csv')
Drag options to blanks, or click blank then click option'
Ato_csv
Bopen_csv
Cload_csv
Dread_csv
Attempts:
3 left
💡 Hint
Common Mistakes
Using to_csv which writes files
Using load_csv which does not exist
Using open_csv which is not a pandas function
3fill in blank
hard

Fix the error in the code to save the DataFrame 'df' to a CSV file named 'output.csv' without the index.

Data Analysis Python
df.to_csv('output.csv', [1]=False)
Drag options to blanks, or click blank then click option'
Aindex
Bno_index
Cinclude_index
Ddrop_index
Attempts:
3 left
💡 Hint
Common Mistakes
Using include_index which is not a valid parameter
Using no_index or drop_index which do not exist
Forgetting to set index to False
4fill in blank
hard

Fill both blanks to create a reproducible random sample of 10 rows from DataFrame 'df'.

Data Analysis Python
sample_df = df.sample(n=[1], random_state=[2])
Drag options to blanks, or click blank then click option'
A10
B42
C100
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Not setting random_state causing different samples each run
Using too large or zero sample size
Confusing n with frac parameter
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each word to its length only if the length is greater than 3.

Data Analysis Python
lengths = { [1]: [2] for [3] in words if len([3]) > 3 }
Drag options to blanks, or click blank then click option'
Aword
Blen(word)
Ditem
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently
Not filtering words with length greater than 3
Using len(item) without defining item