Python Forum
Help: Conversion of Electricity Data into Time Series Data
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help: Conversion of Electricity Data into Time Series Data
#1
I want to plot a power load curve with the electricity consumption data. I download a load profile from a EV charger. The data file is a excel containing the energy start time, stop time, energy consumption and duration data. I have converted the energy data to the load.
   

Now i am stuck how to convert the data into a per-minute time series data similar to the following. Does anyone know how to do the conversion?
   
Reply
#2
Something like this?
import pandas as pd
from datetime import datetime, timedelta


# Read power report spreadsheet
power_report = pd.read_excel("test.xlsx")

# Get starting time.  Here I round down first time in report to the minute.
t = pd.Timestamp(power_report["Energy start time"].values[0]).replace(second=0)

# Get power for each interval
interval = timedelta(minutes=1)
power_usage = []
for start, stop, power in zip(
        power_report["Energy start time"].values,
        power_report["Energy stop time"].values,
        power_report["Power (kW)"].values):

    while t < start:
        power_usage.append({"Time": t, "Load kW": 0.00})
        t += interval
    while t < stop:
        power_usage.append({"Time": t, "Load kW": power})
        t += interval

power_usage = pd.DataFrame(power_usage)
print(power_usage)
Post text, not screenshots. I wrote a little script to make some fake power data and stuff it in a spreadsheet. If you had posted text instead of a screenshot, I could cut/paste and use your data. Make it easy to answer your question and you will get faster and better answers.
Reply
#3
import pandas as pd
import matplotlib.pyplot as plt

# Load your Excel file into a pandas DataFrame
# Assuming your Excel file has columns like 'Start Time', 'Stop Time', 'Energy Consumption', 'Duration'
df = pd.read_excel('your_file.xlsx')

# Convert duration to hours (assuming it's in minutes)
df['Duration (hours)'] = df['Duration'] / 60

# Calculate power load (energy consumption divided by duration)
df['Power Load (kW)'] = df['Energy Consumption'] / df['Duration (hours)']

# Plot the power load curve
plt.figure(figsize=(10, 6))
plt.plot(df['Start Time'], df['Power Load (kW)'], marker='o', linestyle='-')
plt.title('Power Load Curve')
plt.xlabel('Time')
plt.ylabel('Power Load (kW)')
plt.xticks(rotation=45)
plt.grid(True)
plt.tight_layout()
plt.show() 
Reply
#4
The spreadsheet from the original post has an energy start time and and energy stop time. There are gaps betwen the stop time and the next start time. A power usage graph should look like a series of steps, with the power usage as a horizontal line between the start and stop times, and zero between the stop time and the next start time. Granted, a plot of the target format would not be steps either, but would be a closer representation of the data than a line chart showing the power usage at only the start times.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Time Series Production Process Problem Mzarour 1 2,142 Feb-28-2023, 12:25 PM
Last Post: get2sid
  reduce time series based on sum condition amdi40 0 1,112 Apr-06-2022, 09:09 AM
Last Post: amdi40
  How to accumulate volume of time series amdi40 3 2,327 Feb-15-2022, 02:23 PM
Last Post: amdi40
  Recommendations for ML libraries for time-series forecast AndreasPython 0 1,897 Jan-06-2021, 01:03 PM
Last Post: AndreasPython
  Find two extremum in data series Sancho_Pansa 0 1,701 Dec-04-2020, 02:06 PM
Last Post: Sancho_Pansa
  Time Series forecating with multiple independent variables Krychol88 1 1,881 Oct-23-2020, 08:11 AM
Last Post: DPaul
  how to handling time series data file with Python? aupres 4 3,024 Aug-10-2020, 12:40 PM
Last Post: MattKahn13
  Changing Time Series from Start to End of Month illmattic 0 1,889 Jul-16-2020, 10:49 AM
Last Post: illmattic
  HELP- DATA FRAME INTO TIME SERIES- BASIC bntayfur 0 1,771 Jul-11-2020, 09:04 PM
Last Post: bntayfur
  Differencing Time series and Inverse after Training donnertrud 0 4,123 May-27-2020, 06:11 AM
Last Post: donnertrud

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020