如何解决使用数据框绘制温度与20年中的月份的关系图
我正在尝试用单独的线条绘制多年的数据;月vs平均气温。我试图举一个例子,说明我从中获取数据帧以及到目前为止的代码。我想到的一切都会返回错误...一般来说,我是编码和python的新手,只有maltab才是经验。如果您能解释为什么要做某事,那么将大有帮助。
temp =
Year Jan Feb March April May ... Dec
0 2000... 50 50 60 70 80 --- 20
1 ...2020 50 50 60 70 80 --- 20
iterations = len(temp)
months = range(0,13)
for t in range(iterations):
temp_row = temp.loc[t:t,'Jan':'Dec']
display(temp_row)
for k in temp_row:
temp_curve = temp_row[k]
np.array(temp_curve)
display(temp_curve)
#plt.plot(months,temp_curve)
解决方法
这是我将对熊猫进行处理的示例代码。
{
"rules": {
".read": "auth != null",".write": "auth != null","quotes": {
".indexOn": ["businessprofile_id","request_id"]
},"quotes-by-business-profile": {
".indexOn": ["request_id"]
},"businessprofiles": {
"$userid":{
".indexOn": ["status"],".read": "auth.uid == $userid || auth.userId == $userid",".write": "auth.uid == $userid || auth.userId == $userid"
}
},"requests": {
"$requestid":{
".indexOn": ["userid","category","status"]
},".indexOn": ["userid","status","accepted_businessprofile_id"]
},"users" : {
"$users" : {
".read": "auth.uid == $users || auth.userId == $users",".write": "auth.uid == $users || auth.userId == $users"
}
},"messages" : {
".indexOn" : ["request_id","businessprofile_userid","userid","businessprofile_id"]
},"businesslocations" : {
".indexOn": "g"
},"countries" :
{
".read": true
}
}
}
对于您的情况,您需要将数据import pandas as pd
import matplotlib.pyplot as plt
# generate dummy date like yours
temp = pd.DataFrame(np.random.rand(10,12)*30,columns=list('JFMAMJJASOND'),index=[2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,20010])
for irow in temp.iterrows():
irow[1].plot(label=str(irow[0]))
plt.legend(loc='best')
保存到年,然后您才能关注该帖子。
这是我的虚拟数据的样子。 打印(温度)
set_index
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。