@@ -10,7 +10,7 @@ export interface Config {
10
10
* @example
11
11
* const df = pl.DataFrame({abc: [1.0, 2.5, 5.0], xyz: [true, false, true]})
12
12
pl.Config.setAsciiTables(true)
13
- console.log(df.toString());
13
+
14
14
# shape: (3, 2) shape: (3, 2)
15
15
# ┌─────┬───────┐ +-----+-------+
16
16
# │ abc ┆ xyz │ | abc | xyz |
@@ -63,9 +63,9 @@ export interface Config {
63
63
* @param n - Number of rows to display; if `n < 0` (eg: -1), display all rows (DataFrame) and all elements (Series).
64
64
*
65
65
* @example
66
- const df = pl.DataFrame( {abc: [1.0, 2.5, 3.5, 5 .0], xyz: [True, False, True, False]} );
66
+ const df = pl.DataFrame({abc: [1.0, 2.5, 5 .0], xyz: [true, false, true]})
67
67
pl.Config.setTblRows(2);
68
- console.log(df.toString());
68
+
69
69
shape: (4, 2)
70
70
┌─────┬───────┐
71
71
│ abc ┆ xyz │
@@ -87,6 +87,7 @@ export interface Config {
87
87
const df = pl.DataFrame( {abc: [1.0, 2.5, 3.5, 5.0], def: ["d", "e", "f", "g"], xyz: [true, false, true, false] } );
88
88
// Set number of displayed columns to a low value
89
89
pl.Config.setTblCols(2);
90
+
90
91
shape: (4, 3)
91
92
┌─────┬───┬───────┐
92
93
│ abc ┆ … ┆ xyz │
@@ -99,9 +100,65 @@ export interface Config {
99
100
│ 5.0 ┆ … ┆ false │
100
101
└─────┴───┴───────┘
101
102
*/
102
- setTblCols ( ) : Config ;
103
- setTblCols ( n : number ) : Config ;
103
+ setTblCols ( n ?: number ) : Config ;
104
104
105
+ /**
106
+ * Display the data type next to the column name (to the right, in parentheses).
107
+ * @param active - true / false Default - true
108
+ *
109
+ * @example
110
+ --------
111
+ const df = pl.DataFrame({abc: [1.0, 2.5, 5.0], xyz: [true, false, true]})
112
+ pl.Config.setTblColumnDataTypeInline(true)
113
+
114
+ # shape: (3, 2) shape: (3, 2)
115
+ # ┌─────┬───────┐ ┌───────────┬────────────┐
116
+ # │ abc ┆ xyz │ │ abc (f64) ┆ xyz (bool) │
117
+ # │ --- ┆ --- │ ╞═══════════╪════════════╡
118
+ # │ f64 ┆ bool │ │ 1.0 ┆ true │
119
+ # ╞═════╪═══════╡ >> │ 2.5 ┆ false │
120
+ # │ 1.0 ┆ true │ │ 5.0 ┆ true │
121
+ # │ 2.5 ┆ false │ └───────────┴────────────┘
122
+ # │ 5.0 ┆ true │
123
+ # └─────┴───────┘
124
+ */
125
+
126
+ setTblColumnDataTypeInline ( active ?: boolean ) : Config ;
127
+
128
+ /**
129
+ * Hide table column data types (i64, f64, str etc.).
130
+ * @param active - true / false Default - true
131
+
132
+ * @example
133
+ const df = pl.DataFrame({abc: [1.0, 2.5, 5.0], xyz: [true, false, true]})
134
+ pl.Config.setTblHideColumnDataTypes(true)
135
+
136
+ # shape: (3, 2) shape: (3, 2)
137
+ # ┌─────┬───────┐ ┌─────┬───────┐
138
+ # │ abc ┆ xyz │ │ abc ┆ xyz │
139
+ # │ --- ┆ --- │ ╞═════╪═══════╡
140
+ # │ f64 ┆ bool │ │ 1.0 ┆ true │
141
+ # ╞═════╪═══════╡ >> │ 2.5 ┆ false │
142
+ # │ 1.0 ┆ true │ │ 5.0 ┆ true │
143
+ # │ 2.5 ┆ false │ └─────┴───────┘
144
+ # │ 5.0 ┆ true │
145
+ # └─────┴───────┘
146
+ */
147
+ setTblHideColumnDataTypes ( active ?: boolean ) : Config ;
148
+
149
+ /**
150
+ * Enable additional verbose/debug logging.
151
+ * @param active - true / false Default - true
152
+ */
153
+ setVerbose ( active ?: boolean ) : Config ;
154
+
155
+ /**
156
+ * Set the thousands grouping separator character.
157
+ * @param separator : string | bool
158
+ Set True to use the default "," (thousands) and "." (decimal) separators.
159
+ Can also set a custom char, or set ``None`` to omit the separator.
160
+ */
161
+ setThousandsSeparator ( separator ?: string | boolean ) : Config ;
105
162
// TODO: Implement these methods
106
163
// set_auto_structify
107
164
// set_decimal_separator
@@ -113,16 +170,12 @@ export interface Config {
113
170
// set_streaming_chunk_size
114
171
// set_tbl_cell_alignment
115
172
// set_tbl_cell_numeric_alignment
116
- // set_tbl_column_data_type_inline
117
173
// set_tbl_dataframe_shape_below
118
174
// set_tbl_formatting
119
- // set_tbl_hide_column_data_types
120
175
// set_tbl_hide_column_names
121
176
// set_tbl_hide_dataframe_shape
122
177
// set_tbl_hide_dtype_separator
123
- // set_thousands_separator
124
178
// set_trim_decimal_zeros
125
- // set_verbose
126
179
}
127
180
128
181
export const Config : Config = {
@@ -142,4 +195,29 @@ export const Config: Config = {
142
195
pli . setTblCols ( n ) ;
143
196
return this ;
144
197
} ,
198
+ setTblColumnDataTypeInline ( active ?: boolean ) {
199
+ pli . setTblColumnDataTypeInline ( active ? 1 : 0 ) ;
200
+ return this ;
201
+ } ,
202
+ setTblHideColumnDataTypes ( active ?: boolean ) {
203
+ pli . setTblHideColumnDataTypes ( active ? 1 : 0 ) ;
204
+ return this ;
205
+ } ,
206
+ setVerbose ( active ?: boolean ) {
207
+ pli . setVerbose ( active ? 1 : 0 ) ;
208
+ return this ;
209
+ } ,
210
+ setThousandsSeparator ( separator ?: string | boolean ) {
211
+ if ( typeof separator === "boolean" && separator ) {
212
+ pli . setDecimalSeparator ( "." ) ;
213
+ pli . setThousandsSeparator ( "," ) ;
214
+ } else if ( typeof separator === "string" ) {
215
+ if ( separator . length > 1 )
216
+ throw new TypeError ( "separator must be a single character;" ) ;
217
+ pli . setThousandsSeparator ( separator ) ;
218
+ } else {
219
+ pli . setThousandsSeparator ( ) ;
220
+ }
221
+ return this ;
222
+ } ,
145
223
} ;
0 commit comments