Skip to content

Commit

Permalink
Remove system:time_end from dataframe to fix #45
Browse files Browse the repository at this point in the history
  • Loading branch information
aazuspan committed Aug 27, 2022
1 parent a5cdaf5 commit 1eb98c1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
4 changes: 0 additions & 4 deletions test/test_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,16 +431,13 @@ def test_fill_gaps_with_value():
def test_dataframe():
"""Test that a time series dataframe contains the correct start and end times and IDs."""
start_dates = ["2020-01-01", "2020-02-01", "2021-03-03"]
end_dates = ["2020-01-02", "2020-02-03", "2021-04-03"]
ids = ["id1", "id2", "id3"]
col_id = "test_time_series"

imgs = [
ee.Image.constant(1).set(
"system:time_start",
ee.Date(start_dates[i]).millis(),
"system:time_end",
ee.Date(end_dates[i]).millis(),
"system:id",
ids[i],
)
Expand All @@ -451,5 +448,4 @@ def test_dataframe():

assert df.index.id == col_id
assert df.time_start.dt.strftime("%Y-%m-%d").values.tolist() == start_dates
assert df.time_end.dt.strftime("%Y-%m-%d").values.tolist() == end_dates
assert df.id.values.tolist() == ids
4 changes: 1 addition & 3 deletions wxee/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,12 @@ def dataframe(self) -> pd.DataFrame:
A Pandas dataframe where each row represents an image and columns represent system properties.
"""
starts_millis = self.aggregate_array("system:time_start").getInfo()
ends_millis = self.aggregate_array("system:time_end").getInfo()
ids = self.aggregate_array("system:id").getInfo()
collection_id = self.get("system:id").getInfo()

starts = [_millis_to_datetime(ms) for ms in starts_millis]
ends = [_millis_to_datetime(ms) for ms in ends_millis]

df = pd.DataFrame({"id": ids, "time_start": starts, "time_end": ends})
df = pd.DataFrame({"id": ids, "time_start": starts})
df.index.id = collection_id
return df

Expand Down

0 comments on commit 1eb98c1

Please sign in to comment.