【发布时间】:2019-12-06 00:57:45
【问题描述】:
我有一个数据集,需要将其从月度数据转换为季度数据。
这是我数据的前五行。
Measure Name Year Month Value
0 Revenue from Sale of Recycled Materials 2007 Jan $1,757,000
1 Revenue from Sale of Recycled Materials 2007 Feb $2,052,000
2 Revenue from Sale of Recycled Materials 2007 Mar $2,747,000
3 Revenue from Sale of Recycled Materials 2007 Apr $2,308,000
4 Revenue from Sale of Recycled Materials 2007 May $2,289,000
我不知道从哪里开始将每月转换为每季度。
Jan-Mar will be Q1
April-June will be Q2
July-September will be Q3
October-December will be Q4.
我考虑创建一个 Chort 组分析,但由于我的时间数据分为两列,我不知道从哪里开始。
这是我目前的代码
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib as mpl
%matplotlib inline
from pandas_datareader import data as pdr
from pandas.plotting import autocorrelation_plot
import seaborn as sns
from sklearn.metrics import accuracy_score, classification_report
plt.style.use(style='ggplot')
from datetime import datetime
from datetime import timedelta
recycle=pd.read_csv('Pathway link',
sep=',',)
我期待2007 Jan-Mar 成为Q1 等等......
【问题讨论】:
标签: python pandas time-series