import pandas as pd

read excel file into dataframe

df = pd.read_excel('data.xlsx')

filter data from 1947Q1 to 2019Q4

df = df.loc[(df['Year'] >= 1947) & (df['Quarter'] >= 1) & (df['Year'] <= 2019) & (df['Quarter'] <= 4)]

print filtered dataframe

print(df)

用python写代码:Read the data into a dataframe and then only keep the data from 1947Q1 to 2019Q4. (Hint: Look at python_fundamentals_3 notebook on how to read Excel file and do conditional selection of
rows)

原文地址: https://www.cveoy.top/t/topic/yAa 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录