<code>import pandas as pd
df = pd.read_csv('example.csv', encoding='ISO-8859-1')
filtered_df = df.dropna(subset=['SLA_Minuten']).copy()
# Convert 'SLA_Start' to datetime
filtered_df['SLA_Start'] = pd.to_datetime(filtered_df['SLA_Start'], format='%d.%m.%Y %H:%M:%S')
# Define a function to adjust SLA_Added based on working hours
def adjust_sla_added(row):
sla_added = row['SLA_Start'] + pd.to_timedelta(row['SLA_Minuten'], unit='m')
if sla_added.hour >= 17: # Check if the time extends beyond 17:00
next_day_start = sla_added + pd.Timedelta(days=1) # Move to the next day
next_day_start = next_day_start.replace(hour=7, minute=0, second=0, microsecond=0) # Set time to 07:00
elif sla_added.hour < 7: # Check if the time is before 07:00
next_day_start = sla_added.replace(hour=7, minute=0, second=0, microsecond=0) # Set time to 07:00
# Apply the function to create the 'SLA_Added' column
filtered_df['SLA_Added'] = filtered_df.apply(adjust_sla_added, axis=1)
required_data = ['Technischer_Start', 'Prozess_Start', 'SLA_Start', 'SLA_Minuten', 'SLA_Added']
filtered_df[required_data]
<code>import pandas as pd
# Load the CSV file
df = pd.read_csv('example.csv', encoding='ISO-8859-1')
df
#
filtered_df = df.dropna(subset=['SLA_Minuten']).copy()
filtered_df
# Convert 'SLA_Start' to datetime
filtered_df['SLA_Start'] = pd.to_datetime(filtered_df['SLA_Start'], format='%d.%m.%Y %H:%M:%S')
# Define a function to adjust SLA_Added based on working hours
def adjust_sla_added(row):
sla_added = row['SLA_Start'] + pd.to_timedelta(row['SLA_Minuten'], unit='m')
if sla_added.hour >= 17: # Check if the time extends beyond 17:00
next_day_start = sla_added + pd.Timedelta(days=1) # Move to the next day
next_day_start = next_day_start.replace(hour=7, minute=0, second=0, microsecond=0) # Set time to 07:00
return next_day_start
elif sla_added.hour < 7: # Check if the time is before 07:00
next_day_start = sla_added.replace(hour=7, minute=0, second=0, microsecond=0) # Set time to 07:00
return next_day_start
else:
return sla_added
# Apply the function to create the 'SLA_Added' column
filtered_df['SLA_Added'] = filtered_df.apply(adjust_sla_added, axis=1)
# Select required data
required_data = ['Technischer_Start', 'Prozess_Start', 'SLA_Start', 'SLA_Minuten', 'SLA_Added']
filtered_df[required_data]
</code>
import pandas as pd
# Load the CSV file
df = pd.read_csv('example.csv', encoding='ISO-8859-1')
df
#
filtered_df = df.dropna(subset=['SLA_Minuten']).copy()
filtered_df
# Convert 'SLA_Start' to datetime
filtered_df['SLA_Start'] = pd.to_datetime(filtered_df['SLA_Start'], format='%d.%m.%Y %H:%M:%S')
# Define a function to adjust SLA_Added based on working hours
def adjust_sla_added(row):
sla_added = row['SLA_Start'] + pd.to_timedelta(row['SLA_Minuten'], unit='m')
if sla_added.hour >= 17: # Check if the time extends beyond 17:00
next_day_start = sla_added + pd.Timedelta(days=1) # Move to the next day
next_day_start = next_day_start.replace(hour=7, minute=0, second=0, microsecond=0) # Set time to 07:00
return next_day_start
elif sla_added.hour < 7: # Check if the time is before 07:00
next_day_start = sla_added.replace(hour=7, minute=0, second=0, microsecond=0) # Set time to 07:00
return next_day_start
else:
return sla_added
# Apply the function to create the 'SLA_Added' column
filtered_df['SLA_Added'] = filtered_df.apply(adjust_sla_added, axis=1)
# Select required data
required_data = ['Technischer_Start', 'Prozess_Start', 'SLA_Start', 'SLA_Minuten', 'SLA_Added']
filtered_df[required_data]
Technischer_Start Prozess_Start SLA_Start SLA_Minyour text
utenyour text
30.10.2023 10:19:54 30.10.2023 10:19:52 2023-10-30 10:19:52 480.0
please revew my code . so what exactly what i am trying to do is to add SLA_Start with SLA_Minuten and if the time extends 17pm in evening than i have to add it to next day from 7 am but unfoutnaly i am not able to get it . i need to make a column SLA_Finals and show the result in it. Thank you for the help
as the result i am getting i false i would be happy to get help