Documentation for SplinkDataFrame
object¶
Abstraction over dataframe to handle basic operations like retrieving data and
retrieving column names, which need different implementations depending on whether
it's a spark dataframe, sqlite table etc.
Uses methods like as_pandas_dataframe()
and as_record_dict()
to retrieve data
Source code in splink/splink_dataframe.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
as_pandas_dataframe(limit=None)
¶
Return the dataframe as a pandas dataframe.
This can be computationally expensive if the dataframe is large.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit |
int
|
If provided, return this number of rows (equivalent |
None
|
Examples:
df_predict = linker.predict()
df_ten_edges = df_predict.as_pandas_dataframe(10)
Source code in splink/splink_dataframe.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
as_record_dict(limit=None)
¶
Return the dataframe as a list of record dictionaries.
This can be computationally expensive if the dataframe is large.
Examples:
df_predict = linker.predict()
ten_edges = df_predict.as_record_dict(10)
Returns:
Name | Type | Description |
---|---|---|
list |
a list of records, each of which is a dictionary |
Source code in splink/splink_dataframe.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
drop_table_from_database_and_remove_from_cache(force_non_splink_table=False)
¶
Drops the table from the underlying database, and removes it from the (linker) cache.
By default this will fail if the table is not one created by Splink, but this check can be overriden
Examples:
df_predict = linker.predict()
df_predict.drop_table_from_database_and_remove_from_cache()
# predictions table no longer in the database / cache
Source code in splink/splink_dataframe.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
to_csv(filepath, overwrite=False)
¶
Save the dataframe in csv format.
Examples:
df_predict = linker.predict()
df_predict.to_csv("model_predictions.csv", overwrite=True)
Source code in splink/splink_dataframe.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
|
to_parquet(filepath, overwrite=False)
¶
Save the dataframe in parquet format.
Examples:
df_predict = linker.predict()
df_predict.to_parquet("model_predictions.parquet", overwrite=True)
Source code in splink/splink_dataframe.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|