No graph is displaying while plotting value with time interval using python I have a large dataset with values and date and time. So I want to plot graph of value with time and date. So I wrote a code for time difference. Afterthat I tried to store value into that time difference. Afterthat I tried to plot it. It run with no graph. Can anyone helps me to solve this error?
here is my code:

x= df1,iloc[:,2]
time_interval = 14400 #interval in seconds (14400s = 360 minutes)
date_array = []
date_array.append(pd.to_datetime(df1['date'][0]).date())
start_time = []
end_time   = []
temp_date  = pd.to_datetime(df1['date'][0]).date()
start_time.append(pd.to_datetime(df1['time'][0], format='%H:%M:%S').time())
for i in range(len(df1['date'])):
cur_date = pd.to_datetime(df1['date'][i]).date()
if( cur_date &gt; temp_date):
    end_time.append(pd.to_datetime(df1['time'][i-1], format='%H:%M:%S').time())
    start_time.append(pd.to_datetime(df1['time'][i], format='%H:%M:%S').time())
    date_array.append(cur_date)
    temp_date = cur_date
    end_time.append(pd.to_datetime(df1['time'][len(df1['date'])-1], format='%H:%M:%S').time())
  datetime_array = []
  for i in range(len(date_array)):
s_time = datetime.datetime.combine(date_array[i],start_time[i])
e_time = datetime.datetime.combine(date_array[i],  end_time[i])

timediff = (e_time - s_time)
#num_periods = int(timediff.total_seconds()/t3ime_interval) +1 
num_periods = abs(int(timediff.total_seconds()/time_interval)) + 1 
time_list = pd.date_range(start=s_time, end = e_time, periods=num_periods ).to_pydatetime()
datetime_array.extend(time_list)
time_stamps = [datetime.datetime.strftime(t,'%H:%m:%S') for t in datetime_array]
x = np.zeros([num_periods], dtype='timedelta64[s]')
plt.xticks(np.arange(num_periods), time_stamps)


my csv file:



after running the code output came like this:



image:
In python you generally have all the libraries available to you. It is hard to find sometimes but you should rarely need to write out so much code. Try this out.

I created some dummy data using the same date formats as you have:

import pandas as pd
import matplotlib.pyplot as plt

data = {'date': ['08/06/2018', '8/6/2018', '8/6/2018', '9/6/2018'],
        'time': ['6:15:00', '12:45:00', '18:15:00', '6:15:00'],
        'x2': [1, 4, 8, 6]}


Now we will make a pandas DataFrame with this dummy data

df = pd.DataFrame(data)


Now we can get our x-axis datetimes by first concatenating the dates and times together separated by a space. Then we will get pandas to parse these datetimes.

datetimes = pd.to_datetime(df['date'] + ' ' + df['time'], 
                           format='%d/%m/%Y %H:%M:%S')


You can then plot your data using

plt.plot(datetimes, df['x2'])






Put your csv file in your workspace. Then you can use this following code

import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_csv(r'temp.csv')
datetimes = pd.to_datetime(df['date'] + ' ' + df['time'], 
                           format='%d/%m/%Y %H:%M:%S')

plt.plot(datetimes, df['x'])
plt.show()






import matplotlib.dates as mdates

fig, ax = plt.subplots(1)
fig.autofmt_xdate()

plt.plot(datetimes, df['x'])
plt.xticks(rotation=90)

xfmt = mdates.DateFormatter('%d-%m-%y %H:%M')
ax.xaxis.set_major_formatter(xfmt)
plt.show()