2525 "value_updated_timestamp" : "Int64" ,
2626}
2727
28+
2829@dataclass
2930class CovidcastRow :
3031 """A container for the values of a single covidcast database row.
@@ -35,7 +36,8 @@ class CovidcastRow:
3536 - converting from and to formats (dict, csv, df, kwargs)
3637 - creating consistent views, with consistent data types (dict, csv, df)
3738
38- The rows are specified in 'v4_schema.sql'. The datatypes are made to match database. When writing to Pandas, the dtypes match the JIT model.py schema.
39+ The rows are specified in 'v4_schema.sql'. The datatypes are made to match
40+ database. When writing to Pandas, the dtypes match the JIT model.py schema.
3941 """
4042
4143 # Arguments.
@@ -54,15 +56,20 @@ class CovidcastRow:
5456 missing_sample_size : int
5557 issue : int
5658 lag : int
57- # The following three fields are only the database, but are not ingested at acquisition and not returned by the API.
59+ # The following three fields are only in the database, but are not ingested at
60+ # acquisition and not returned by the API.
5861 epimetric_id : Optional [int ] = None
5962 direction : Optional [int ] = None
6063 value_updated_timestamp : Optional [int ] = 0
6164
6265 # Classvars.
6366 _db_row_ignore_fields : ClassVar = []
6467 _api_row_ignore_fields : ClassVar = ["epimetric_id" , "value_updated_timestamp" ]
65- _api_row_compatibility_ignore_fields : ClassVar = _api_row_ignore_fields + ["source" , "time_type" , "geo_type" ]
68+ _api_row_compatibility_ignore_fields : ClassVar = _api_row_ignore_fields + [
69+ "source" ,
70+ "time_type" ,
71+ "geo_type" ,
72+ ]
6673
6774 _pandas_dtypes : ClassVar = PANDAS_DTYPES
6875
@@ -72,17 +79,22 @@ def as_dict(self, ignore_fields: Optional[List[str]] = None) -> dict:
7279 for key in ignore_fields :
7380 del d [key ]
7481 return d
75-
82+
7683 def as_api_row_dict (self , ignore_fields : Optional [List [str ]] = None ) -> dict :
77- """Returns a dict view into the row with the fields returned by the API server."""
84+ """Returns a dict view into the row with the fields returned by the API
85+ server."""
7886 return self .as_dict (ignore_fields = self ._api_row_ignore_fields + (ignore_fields or []))
7987
8088 def as_api_compatibility_row_dict (self , ignore_fields : Optional [List [str ]] = None ) -> dict :
81- """Returns a dict view into the row with the fields returned by the old API server (the PHP server)."""
82- return self .as_dict (ignore_fields = self ._api_row_compatibility_ignore_fields + (ignore_fields or []))
89+ """Returns a dict view into the row with the fields returned by the old
90+ API server (the PHP server)."""
91+ return self .as_dict (
92+ ignore_fields = self ._api_row_compatibility_ignore_fields + (ignore_fields or [])
93+ )
8394
8495 def as_db_row_dict (self , ignore_fields : Optional [List [str ]] = None ) -> dict :
85- """Returns a dict view into the row with the fields returned by the database."""
96+ """Returns a dict view into the row with the fields returned by the
97+ database."""
8698 return self .as_dict (ignore_fields = self ._db_row_ignore_fields + (ignore_fields or []))
8799
88100 def as_dataframe (self , ignore_fields : Optional [List [str ]] = None ) -> pd .DataFrame :
@@ -92,15 +104,22 @@ def as_dataframe(self, ignore_fields: Optional[List[str]] = None) -> pd.DataFram
92104 return df
93105
94106 def as_api_row_df (self , ignore_fields : Optional [List [str ]] = None ) -> pd .DataFrame :
95- """Returns a dataframe view into the row with the fields returned by the API server."""
107+ """Returns a dataframe view into the row with the fields returned by the
108+ API server."""
96109 return self .as_dataframe (ignore_fields = self ._api_row_ignore_fields + (ignore_fields or []))
97110
111+ # fmt: off
98112 def as_api_compatibility_row_df (self , ignore_fields : Optional [List [str ]] = None ) -> pd .DataFrame :
99- """Returns a dataframe view into the row with the fields returned by the old API server (the PHP server)."""
100- return self .as_dataframe (ignore_fields = self ._api_row_compatibility_ignore_fields + (ignore_fields or []))
113+ """Returns a dataframe view into the row with the fields returned by the
114+ old API server (the PHP server)."""
115+ # fmt: on
116+ return self .as_dataframe (
117+ ignore_fields = self ._api_row_compatibility_ignore_fields + (ignore_fields or [])
118+ )
101119
102120 def as_db_row_df (self , ignore_fields : Optional [List [str ]] = None ) -> pd .DataFrame :
103- """Returns a dataframe view into the row with the fields returned by an all-field database query."""
121+ """Returns a dataframe view into the row with the fields returned by an
122+ all-field database query."""
104123 return self .as_dataframe (ignore_fields = self ._db_row_ignore_fields + (ignore_fields or []))
105124
106125 def signal_pair (self ):
@@ -113,7 +132,6 @@ def time_pair(self):
113132 return f"{ self .time_type } :{ self .time_value } "
114133
115134
116-
117135def check_valid_dtype (dtype ):
118136 try :
119137 pd .api .types .pandas_dtype (dtype )
0 commit comments