Last active
January 25, 2022 02:35
-
-
Save jskherman/9f91be0d6b08d9710382c23d39335dea to your computer and use it in GitHub Desktop.
Script to parse the generated CSV from the Forest App into a pandas dataframe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to parse the csv from the Forest App into a pandas dataframe | |
#%% | |
import pandas as pd | |
from datetime import datetime | |
### Specify pattern for dates in Forest's csv export for dateparser | |
dateparse = lambda x: datetime.strptime(x, "%a %b %d %H:%M:%S %Z%z %Y") | |
### Sidenote: Alternative regex patterns | |
### (1) "%a %b %d %H:%M:%S GMT+08:00 %Y" | |
### (2) "%a %b %d %H:%M:%S %Z%z %Y" | |
#%% | |
### Read the CSV | |
df = pd.read_csv("Plants.csv", parse_dates=["Start Time", "End Time"], date_parser=dateparse) | |
df.head() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment