Changeset 1050
- Timestamp:
- 06/22/08 16:41:09 (2 months ago)
- Files:
-
- trunk/timeseries/scikits/timeseries/tseries.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/timeseries/scikits/timeseries/tseries.py
r1048 r1050 1376 1376 def align_series(*series, **kwargs): 1377 1377 """Aligns several TimeSeries, so that their starting and ending dates match. 1378 Series are resized and filled with mased values accordingly. 1378 Series are resized and filled with masked values accordingly. The resulting 1379 series have no missing dates (ie. series.isvalid() == True for each of the 1380 resulting series). 1379 1381 1380 1382 The function accepts two extras parameters: … … 1388 1390 unique_freqs = np.unique([x.freqstr for x in series]) 1389 1391 common_freq = _compare_frequencies(*series) 1390 valid_states = [x.isvalid() for x in series] 1391 if not np.all(valid_states): 1392 raise TimeSeriesError, \ 1393 "Cannot adjust a series with missing or duplicated dates." 1392 1393 # if any of the series have missing dates, fill them in first 1394 filled_series = [] 1395 for ser in series: 1396 if ser.isvalid(): 1397 filled_series.append(ser) 1398 else: 1399 filled_series.append(ser.fill_missing_dates()) 1394 1400 1395 1401 start_date = kwargs.pop('start_date', 1396 min([x.start_date for x in series1402 min([x.start_date for x in filled_series 1397 1403 if x.start_date is not None])) 1398 1404 if isinstance(start_date,str): 1399 1405 start_date = Date(common_freq, string=start_date) 1400 1406 end_date = kwargs.pop('end_date', 1401 max([x.end_date for x in series1407 max([x.end_date for x in filled_series 1402 1408 if x.end_date is not None])) 1403 1409 if isinstance(end_date,str): 1404 1410 end_date = Date(common_freq, string=end_date) 1405 1411 1406 return [adjust_endpoints(x, start_date, end_date) for x in series]1412 return [adjust_endpoints(x, start_date, end_date) for x in filled_series] 1407 1413 aligned = align_series 1408 1414
