Basic Python Data Processing Operation Exercise (EDUCODER)

Practice of Basic Data Processing Operations

Title

First level

Display the name of the company whose last transaction price was greater than the query criteria among the constituent stocks of the Dow Jones Index
Programming requirements.

Open the 'step1/stock30. csv' file, enter a positive integer as the query criterion, use the condition filter to find the company with the last transaction price greater than this criterion, and display the name of the company.

Second level

Calculate the total transaction volume for the top 10 days in the past month for American Express.

Programming requirements Open 'step2/quotesdf'_m. CSV file, filter out data from the past month, and then arrange it in descending order of increase. Take the top 10 records to calculate the total transaction volume.

Reference code

First level
import pandas as pd 
IN = int(input())
RS=pd.read_csv('step1/stock30.csv')
DATEF = pd.DataFrame(RS,columns=['name','lasttrade'])
DATEF.index = DATEF.index + 1
print(DATEF.loc[DATEF.lasttrade > IN].name)
Second level
import pandas as pd
RS = pd.read_csv('step2/quotesdf_m.csv')#read file 
RS.columns = ['date', 'close', 'high', 'low', 'open', 'volume', 'month']
RS.index = 1 + RS.index
INCR = RS.close - RS.open
RS['increase'] = INCR.values
rs = RS[RS.date >= '2020/2/28']
tem = rs.sort_values(by="increase", ascending=False)
SUL = tem[:10]
print(sum(SUL.volume))
###### End ######