Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12141

How can I find an ValueError in my dataset? [closed]

$
0
0

I have a dataset containing time values, and each time it runs, it brings up the same error "ValueError: time data "['12:00'" does not match format '%H:%M'".I have tried to look for the error manually but I could not find it. Please, if you know a way I could find where the error is in the dataset, I'd be most grateful. This is the code below

import pandas as pdfrom datetime import datetime# Read user data from CSV filedef read_user_data(file_path):    df = pd.read_csv(file_path)    user_data = {'start_screen_time': datetime.strptime(df['start_screen_time'].iloc[0], "%H:%M"),'preferred_notification_times': [datetime.strptime(t.strip(), "%H:%M") for t in df['preferred_notification_times'].iloc[0].split(',')],'frequent_screen_time': [datetime.strptime(t.strip(), "%H:%M") for t in df['frequent_screen_time'].iloc[0].split(',')],'priority_notifications': dict(zip(df['task'], df['priority'])),'time_window': dict(zip(df['task'], df['time_window']))    }    return user_data# ... other functions ...# Example usagefile_path = 'train_augmented_new.csv'user_data = read_user_data(file_path)

And this is the error

ValueError                                Traceback (most recent call last)<ipython-input-3-96f308e3bb86> in <cell line: 80>()     78 # Example usage     79 file_path = 'train_augmented_new.csv'---> 80 user_data = read_user_data(file_path)     81 schedule = schedule_notifications(user_data)     82 3 frames/usr/lib/python3.10/_strptime.py in _strptime(data_string, format)    347     found = format_regex.match(data_string)    348     if not found:--> 349         raise ValueError("time data %r does not match format %r" %    350                          (data_string, format))    351     if len(data_string) != found.end():ValueError: time data "['12:00'" does not match format '%H:%M

Viewing all articles
Browse latest Browse all 12141

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>