strawman
dummy_df(shape, content_length=3, allowed_chars=string.ascii_letters, columns=None, seed=None)
Create a dummy DataFrame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shape |
Tuple[int, int]
|
Dimensions of the DataFrame |
required |
content_length |
int
|
length of the strings in the cells |
3
|
allowed_chars |
str
|
string containing the allowed chars |
ascii_letters
|
columns |
List[str]
|
columns names |
None
|
seed |
int
|
seed for reproducibility |
None
|
Returns:
Type | Description |
---|---|
DataFrame
|
Randomly generated DataFrame |
Raises:
Type | Description |
---|---|
ValueError
|
if length of columns does not match shape |
Example:
>>> from strawman import dummy_df
>>> dummy_df((10,3))
0 1 2
0 Ass wEB jEx
1 xxD TtW Xzs
2 ITh mpj tgy
3 rgN ZyW kzR
4 FPO XiY ARn
5 gCh ArF QlR
6 AxL PMg oMG
7 cBo NEN ljX
8 mpT rjh smJ
9 lZe Krw TRs
Source code in /home/docs/checkouts/readthedocs.org/user_builds/strawman/envs/latest/lib/python3.10/site-packages/strawman/dummy_pandas.py
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 |
|
dummy_triples(length, num_entities=None, num_rel=None, entity_prefix='e', relation_prefix='rel', relation_triples=True, entity_ids=None, relation_ids=None, columns=None, content_length=3, allowed_chars=string.ascii_letters, seed=None)
Create dummy DataFrame in form of triples.
The default columns are ["head","relation","tail"].
Entries in the head column have an entity_prefix
("e" by default),
with numbers as suffix. This is analagously done for the entries
in the relation column but with the relation_prefix
.
All entities show up at least once. Self-links (e.g. ["e1", "rel1", "e1"]) are avoided.
If relation_triples
is False, the last column contains randomly generated strings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
length |
int
|
Length of the DataFrame |
required |
num_entities |
int
|
Number of unique entities |
None
|
num_rel |
int
|
Number of unique relations |
None
|
entity_prefix |
str
|
Prefix for entity strings |
'e'
|
relation_prefix |
str
|
Prefix for relation strings |
'rel'
|
relation_triples |
bool
|
If True the last column contains entities, else randomly generated string |
True
|
entity_ids |
List[str]
|
Predefined entity ids |
None
|
relation_ids |
List[str]
|
Predefined relation ids |
None
|
columns |
List[str]
|
Column names ["head","relation","tail"] by default |
None
|
content_length |
int
|
Length of randomly generated string |
3
|
allowed_chars |
str
|
Allowed characters in randomly generated string |
ascii_letters
|
seed |
int
|
Seed for reproducibility. |
None
|
Returns:
Type | Description |
---|---|
DataFrame
|
randomly generated triple DataFrame |
Raises:
Type | Description |
---|---|
ValueError
|
If dummy_triples cannot be generated with the given specifications |
Example:
>>> from strawman import dummy_triples
>>> df = dummy_triples(10)
>>> df
head relation tail
0 e4 rel1 e0
1 e3 rel1 e1
2 e0 rel1 e5
3 e6 rel2 e3
4 e6 rel0 e4
5 e1 rel1 e0
6 e2 rel1 e0
7 e5 rel1 e3
8 e6 rel2 e0
9 e6 rel0 e2
Create an attribute triple DataFrame with predefined entities
>>> dummy_triples(10, entity_ids=set(df["head"]), relation_triples=False)
head relation tail
0 e5 rel1 LOR
1 e6 rel1 rmM
2 e4 rel2 rmM
3 e0 rel2 LOR
4 e1 rel0 rmM
5 e5 rel2 Mda
6 e2 rel1 yhf
7 e3 rel2 ata
8 e5 rel2 gHk
9 e5 rel0 rmM
Source code in /home/docs/checkouts/readthedocs.org/user_builds/strawman/envs/latest/lib/python3.10/site-packages/strawman/dummy_pandas.py
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 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
|