Reputation: 1
I am doing a practice with Pandas and have to create a dataframe from .csv
files like this
file1_df = pd.read_csv(path1, index_col = ['date'], parse_dates = True, usecols = ['date', 'close'])
file2_df = pd.read_csv(path2, index_col = ['date'], parse_dates = True, usecols = ['date', 'close'])
Then I have to create a calendar starting from the oldest date (2013-02-08) to the more recent (2018-02-07) that are in the dataframes. Both files start and end with the same dates so I did this:
min_date = '2013-02-08'
max_date = '2018-02-07'
dates = pd.date_range(min_date, max_date)
This actually solved the problem since I know where they start and end but I think there must be other ways that could do it. I have problems mostly because the dates are the index and didnt find any method to work with them.
And one more think in case of they start or end at diferent dates how can I compare them?
Upvotes: 0
Views: 2015
Reputation: 2786
pd.index.min()
and pd.index.max()
will give you the min and max values you are looking for.
Upvotes: 2