Skip to content

Commit

Permalink
docs: wip - improve doc structure
Browse files Browse the repository at this point in the history
  • Loading branch information
universalmind303 committed Dec 30, 2022
1 parent 80ebace commit befddc7
Show file tree
Hide file tree
Showing 37 changed files with 3,867 additions and 3,370 deletions.
Binary file modified .yarn/install-state.gz
Binary file not shown.
10 changes: 5 additions & 5 deletions @types/jest.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {DataFrame} from "@polars/dataframe";
import {Series} from "@polars/series/series";
import {Series} from "@polars/series";

declare global {
namespace jest {
Expand All @@ -12,11 +12,11 @@ declare global {
*
* @example
* ```
* >>> df = pl.Dataframe([pl.Series("int32": [1,2], pl.Int32)])
* >>> other = pl.Dataframe([pl.Series("int32": [1,2], pl.UInt32)])
* > df = pl.Dataframe([pl.Series("int32": [1,2], pl.Int32)])
* > other = pl.Dataframe([pl.Series("int32": [1,2], pl.UInt32)])
*
* >>> expect(df).toFrameEqual(other) // passes
* >>> expect(df).toFrameStrictEqual(other) // fails
* > expect(df).toFrameEqual(other) // passes
* > expect(df).toFrameStrictEqual(other) // fails
* ```
*/
toFrameStrictEqual(b: DataFrame): R;
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,45 @@ const pl = require('nodejs-polars');
### Series

```js
>>> const fooSeries = pl.Series("foo", [1, 2, 3])
>>> fooSeries.sum()
>const fooSeries = pl.Series("foo", [1, 2, 3])
>fooSeries.sum()
6

// a lot operations support both positional and named arguments
// you can see the full specs in the docs or the type definitions
>>> fooSeries.sort(true)
>>> fooSeries.sort({reverse: true})
>fooSeries.sort(true)
>fooSeries.sort({reverse: true})
shape: (3,)
Series: 'foo' [f64]
[
3
2
1
]
>>> fooSeries.toArray()
>fooSeries.toArray()
[1, 2, 3]

// Series are 'Iterables' so you can use javascript iterable syntax on them
>>> [...fooSeries]
>[...fooSeries]
[1, 2, 3]

>>> fooSeries[0]
>fooSeries[0]
1

```

### DataFrame

```js
>>> const df = pl.DataFrame(
>const df = pl.DataFrame(
... {
... A: [1, 2, 3, 4, 5],
... fruits: ["banana", "banana", "apple", "apple", "banana"],
... B: [5, 4, 3, 2, 1],
... cars: ["beetle", "audi", "beetle", "beetle", "beetle"],
... }
... )
>>> df
>df
... .sort("fruits")
... .select(
... "fruits",
Expand Down Expand Up @@ -90,7 +90,7 @@ shape: (5, 8)
```

```js
>>> df["cars"] // or df.getColumn("cars")
>df["cars"] // or df.getColumn("cars")
shape: (5,)
Series: 'cars' [str]
[
Expand Down
1 change: 0 additions & 1 deletion __tests__/groupby.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pl from "@polars";

describe("groupby", () => {
let df: pl.DataFrame;
beforeEach(() => {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
"source-map-support": "^0.5.21",
"ts-jest": "^27.1.0",
"ts-node": "^10.4.0",
"typedoc": "^0.22.9",
"typescript": "4.4.3"
"typedoc": "^0.23",
"typescript": "4.9"
},
"packageManager": "yarn@3.3.1",
"workspaces": [
Expand Down
28 changes: 17 additions & 11 deletions polars/cfg.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
import pli from "./native-polars";

/**
* Configure polars; offers options for table formatting and more.
*/
export interface Config {
/** Use utf8 characters to print tables */
setUtf8Tables(): Config
setUtf8Tables(): Config;
/** Use ascii characters to print tables */
setAsciiTables(): Config
setAsciiTables(): Config;
/** Set the number of character used to draw the table */
setTblWidthChars(width: number): Config
setTblWidthChars(width: number): Config;
/** Set the number of rows used to print tables */
setTblRows(n: number): Config
setTblRows(n: number): Config;
/** Set the number of columns used to print tables */
setTblCols(n: number): Config
setTblCols(n: number): Config;
/** Turn on the global string cache */
setGlobalStringCache(): Config
setGlobalStringCache(): Config;
/** Turn off the global string cache */
unsetGlobalStringCache(): Config
unsetGlobalStringCache(): Config;
}

/**
* @ignore
*/
export const Config: Config = {
setUtf8Tables() {

delete process.env["POLARS_FMT_NO_UTF8"];
process.env["POLARS_FMT_NO_UTF8"] = undefined;

return this;
},
Expand All @@ -28,7 +35,6 @@ export const Config: Config = {
return this;
},
setTblWidthChars(width) {

process.env["POLARS_TABLE_WIDTH"] = String(width);

return this;
Expand All @@ -52,5 +58,5 @@ export const Config: Config = {
pli.toggleStringCache(false);

return this;
}
},
};
Loading

0 comments on commit befddc7

Please sign in to comment.