Python Forum
Help me in extracting the datetime from netcdf file - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: Code sharing (https://python-forum.io/forum-5.html)
+--- Thread: Help me in extracting the datetime from netcdf file (/thread-33812.html)



Help me in extracting the datetime from netcdf file - aimanumer444 - May-29-2021

Hi everyone i am having netcd file and have the time in numeric one wanna convert it to Georgian one i am using these codes but its giving me error.Kindly help me with this. but its giving me cannot convert to timestamp
from netCDF4 import Dataset
import numpy as np
import pandas as pd



data = Dataset(r'C:\Users\hp\Desktop\lhr 2015.nc', 'r')\
#reainging file
#print(data.variables.keys())

lon = data.variables['longitude'][:]

lat = data.variables['latitude'][:]

time = data.variables['time'] [:]
 
starting_date=data.variables ['time'] .units[14:24]

ending_date=data.variables ['time'].units [14:18]+ '-12-31'

date_range= pd.date_range (start=starting_date,end=ending_date,periods=8784,freq='H')