【问题标题】:How can i read excel file and plot daily rainfall time series我如何阅读excel文件并绘制每日降雨时间序列
【发布时间】:2016-09-09 09:29:21
【问题描述】:

如何将 08:45 时间转换为 0845 以便绘制时间序列降雨量

import numpy as np
import csv as csv
import pandas as pd
import datetime
import time
import matplotlib.pylab as plt
from mpl_toolkits.mplot3d import Axes3D
filename ='/home/yogesh/RTDAS 20 St.Data/Ambeghar_Rainfall.xls'
viewdata = pd.read_excel(filename, delimiter = ',',skiprows = 6,usecols=([3,4,5,6]))
index_col = 'Date'
fig1 = plt.figure(figsize=(25, 15))
ax1 = fig1.add_subplot(111)
plt.plot(viewdata["Today's Rain\n(mm)"])
plt.title("Rain Rate")
plt.show()

输出:

【问题讨论】:

  • SO 不是代码编写服务,请展示您的努力、示例数据、代码、任何错误和所需的输出
  • import numpy as np import csv as csv import pandas as pd import datetime import time import matplotlib.pylab as plt from mpl_toolkits.mplot3d import Axes3D filename ='/home/yogesh/RTDAS 20 St.Data/ Ambeghar_Rainfall.xls' viewdata = pd.read_excel(filename, delimiter = ',',skiprows = 6,usecols=([3,4,5,6])) #,index_col = 'Date' fig1 = plt.figure(figsize =(25, 15)) ax1 = fig1.add_subplot(111) plt.plot(viewdata["今天的雨\n(mm)"]) plt.title("降雨率") plt.show()
  • 将代码编辑到您的问题中,cmets 丢失格式
  • 如果该编辑通过,它仍然需要正确缩进

标签: python pandas matplotlib


【解决方案1】:
import numpy as np
import pandas as pd
import matplotlib.pylab as plt
filename ='/home/yogesh/RTDAS 20 St.Data/Ambeghar_Rainfall.xls'

# The standard variable name for a DataFrame is df.
df = pd.read_excel(filename, delimiter = ',', skiprows=6,usecols=([3,4,5,6]))

#I'm not sure if this is used later, or if you're trying to set index_col as your column name.
index_col = 'Date'
df = df.set_index(index_col)

# If you're only looking to plot a single column this is often easier:
df["Today's Rain\n(mm)"].plot(figsize=(25, 15))
plt.title("Rain Rate")
plt.show()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-30
    • 1970-01-01
    • 1970-01-01
    • 2021-10-25
    • 1970-01-01
    相关资源
    最近更新 更多