1818
1919
2020def validate (df ):
21- """Confirms that a data frame has only one date."""
21+ """Confirm that a data frame has only one date."""
2222 timestamps = df ['date_range_start' ].apply (date_from_timestamp )
2323 assert len (timestamps .unique ()) == 1
2424
2525
2626def date_from_timestamp (timestamp ) -> datetime .date :
27- """Extracts the date from a timestamp beginning with {YYYY}-{MM}-{DD}T."""
27+ """Extract the date from a timestamp beginning with {YYYY}-{MM}-{DD}T."""
2828 return datetime .date .fromisoformat (timestamp .split ('T' )[0 ])
2929
3030
3131def files_in_past_week (current_filename ) -> List [str ]:
32- """Constructs file paths from previous 6 days.
32+ """Construct file paths from previous 6 days.
33+
3334 Parameters
3435 ----------
3536 current_filename: str
@@ -51,12 +52,13 @@ def files_in_past_week(current_filename) -> List[str]:
5152
5253
5354def add_suffix (signals , suffix ):
54- """Adds `suffix` to every element of `signals`."""
55+ """Add `suffix` to every element of `signals`."""
5556 return [s + suffix for s in signals ]
5657
5758
5859def construct_signals (cbg_df , signal_names ):
5960 """Construct Census-block level signals.
61+
6062 In its current form, we prepare the following signals in addition to those
6163 already available in raw form from Safegraph:
6264 - completely_home_prop, defined as:
@@ -80,7 +82,6 @@ def construct_signals(cbg_df, signal_names):
8082 Dataframe with columns: timestamp, county_fips, and
8183 {each signal described above}.
8284 """
83-
8485 # Preparation
8586 cbg_df ['county_fips' ] = (cbg_df ['origin_census_block_group' ] // MOD ).apply (
8687 lambda x : f'{ int (x ):05d} ' )
@@ -105,6 +106,7 @@ def construct_signals(cbg_df, signal_names):
105106
106107def aggregate (df , signal_names , geo_resolution = 'county' ):
107108 """Aggregate signals to appropriate resolution and produce standard errors.
109+
108110 Parameters
109111 ----------
110112 df: pd.DataFrame
@@ -156,9 +158,10 @@ def process_window(df_list: List[pd.DataFrame],
156158 signal_names : List [str ],
157159 geo_resolutions : List [str ],
158160 export_dir : str ):
159- """Processes a list of input census block group-level data frames as a
160- single data set and exports it. Assumes each data frame has _only_ one
161- date of data.
161+ """Process a list of input census block group-level data frames as a single data set and export.
162+
163+ Assumes each data frame has _only_ one date of data.
164+
162165 Parameters
163166 ----------
164167 cbg_df: pd.DataFrame
@@ -200,8 +203,8 @@ def process(filenames: List[str],
200203 wip_signal ,
201204 geo_resolutions : List [str ],
202205 export_dir : str ):
203- """Creates and exports signals corresponding both to a single day as well
204- as averaged over the previous week.
206+ """Create and exports signals corresponding both single day and averaged over the previous week.
207+
205208 Parameters
206209 ----------
207210 current_filename: List[str]
0 commit comments