// To convert json datetime string to datetime object in c#
// Try this
// For instance if the json string is in this format: "/Date(1409202000000-0500 )/"
// Then wrap it like below
string sa = @"""/Date(1409202000000-0500)/""";
// Create a new instance of datetime object
DateTime dt = new DateTime();
// Deserialize the json string to datetime object
dt = JsonConvert.DeserializeObject<DateTime>(sa);
// Output
// dt = "2014-08-28 3.00.00 PM"
Load libraries
import pandas as pd
from datetime import timedelta
# Loading dataset and creating duration column
url = 'https://drive.google.com/uc?id=1YV5bKobzYxVAWyB7VlxNH6dmfP4tHBui'
df = pd.read_csv(url, parse_dates = ['pickup_datetime', 'dropoff_datetime', 'dropoff_calculated'])
df["duration"] = pd.to_timedelta(df["duration"])
# Task 1 - filter to only rides with negative durations
df_neg = df[___["___"] < ___(___)]
# Task 2 - iterate over df_neg rows to find inconsistencies
count = 0
for i, row in df_neg.___():
# Compare minutes of dropoff_datetime and dropoff_calculated
if row["___"].___ != row["___"].minute:
# Print these two columns
print(___[["dropoff_datetime", "dropoff_calculated"]])
# Task 3 - count number of rows having hour greater-equal than 12
if row["___"].___ >= ___:
count ___
print(f"There are {count} rows in df_neg having hour greater-equal than 12.")
string CurrentDate = "06/04/2020";
// Creating new CultureInfo Object
// You can use different cultures like French, Spanish etc.
CultureInfo Culture = new CultureInfo("en-US");
//Use of Convert.ToDateTime()
DateTime DateObject = Convert.ToDateTime(CurrentDate, Culture);
Console.WriteLine("The Date is: " + DateObject.Day + " " + DateObject.Month + " " + DateObject.Year);