0
0
Data Analysis Pythondata~10 mins

Financial data analysis pattern 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 load financial data from a CSV file into a DataFrame.

Data Analysis Python
import pandas as pd

data = pd.[1]('financial_data.csv')
Drag options to blanks, or click blank then click option'
Ato_csv
Bread_csv
Cread_excel
Dread_json
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'read_excel' when the file is a CSV.
Using 'to_csv' which is for saving, not loading.
2fill in blank
medium

Complete the code to calculate the daily returns from the 'Close' price column.

Data Analysis Python
data['Daily_Return'] = data['Close'].[1]()
Drag options to blanks, or click blank then click option'
Apct_change
Bdiff
Ccumsum
Dmean
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'diff' which calculates absolute difference, not percentage.
Using 'cumsum' which accumulates sums, not returns.
3fill in blank
hard

Fix the error in the code to filter rows where the 'Volume' is greater than 1 million.

Data Analysis Python
high_volume = data[data['Volume'] [1] 1000000]
Drag options to blanks, or click blank then click option'
A==
B<
C>
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' or '<=' which select smaller volumes.
Using '==' which selects only volumes exactly equal to 1 million.
4fill in blank
hard

Fill both blanks to create a dictionary of average closing prices for each stock symbol.

Data Analysis Python
avg_close = {symbol: data[data['Symbol'] == symbol]['[1]'].[2]() for symbol in data['Symbol'].unique()}
Drag options to blanks, or click blank then click option'
AClose
BVolume
Cmean
Dsum
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Volume' instead of 'Close' for price data.
Using 'sum' instead of 'mean' for average.
5fill in blank
hard

Fill all three blanks to create a filtered DataFrame with stocks having positive daily returns and volume above 500,000.

Data Analysis Python
filtered_data = data[(data['Daily_Return'] [1] 0) & (data['Volume'] [2] 500000)]
result = filtered_data[['[3]', 'Daily_Return', 'Volume']]
Drag options to blanks, or click blank then click option'
A>
B>=
CSymbol
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' for filtering positive returns.
Selecting wrong columns in the final DataFrame.