To find the minimum date in a Pandas DataFrame, you can use the DataFrame.min
method along with the to_datetime
function to convert the date column to a datetime data type.
For example, given a DataFrame df
with a column date
containing dates in the format YYYY-MM-DD
, you can find the minimum date using the following code:
import pandas as pd
# Convert the date column to datetime
df['date'] = pd.to_datetime(df['date'])
# Find the minimum date
min_date = df['date'].min()
print(min_date)
This will output the minimum date as a Pandas Timestamp object. You can use the strftime
method to format the date as a string if needed. For example:
min_date_str = min_date.strftime('%Y-%m-%d')
print(min_date_str)