Skip to content

Commit 0805805

Browse files
committed
Add/Update Typescript types for new features in browser
1 parent f2d4d19 commit 0805805

27 files changed

+2718
-1133
lines changed

danfojs-browser/src/core/generic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ export default class NDframe {
414414
/**
415415
* Converts a DataFrame or Series to JSON.
416416
* @param options Configuration object. Supported options:
417-
* - `filePath`: The file path to write the JSON to. If not specified, the JSON object is returned.
417+
* - `fileName`: The file path to write the JSON to. If not specified, the JSON object is returned.
418418
* - `format`: The format of the JSON. Defaults to `'column'`. E.g for using `column` format:
419419
* ```
420420
* [{ "a": 1, "b": 2, "c": 3, "d": 4 },

danfojs-browser/src/io/io.csv.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ import { DataFrame } from '../index';
4444
* const df = await readCSV("./data/sample.csv")
4545
* ```
4646
*/
47-
const $readCSV = async (file, options) => {
47+
const $readCSV = async (filePath, options) => {
4848
options = { header: true, dynamicTyping: true, ...options };
4949
return new Promise((resolve) => {
50-
Papa.parse(file, {
50+
Papa.parse(filePath, {
5151
...options,
5252
download: true,
5353
complete: (results) => {

danfojs-browser/types/config/config.d.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
/**
2+
* @license
3+
* Copyright 2021, JsData. All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
* ==========================================================================
14+
*/
15+
import Series from "./series";
16+
import { ArrayType1D, DateTime } from "../shared/types";
17+
/**
18+
* Format and handle all datetime operations on Series or Array of date strings
19+
* @param data Series or Array of date strings
20+
*/
21+
export default class TimeSeries implements DateTime {
22+
private $dateObjectArray;
23+
constructor(data: Series | ArrayType1D);
24+
/**
25+
* Processed the data values into internal structure for easy access
26+
* @param dateArray An array of date strings
27+
*/
28+
private processData;
29+
/**
30+
* Returns the month, in local time.
31+
* @example
32+
* ```
33+
* import { Dataframe } from "danfojs-node"
34+
* const data = [
35+
* "2019-01-01",
36+
* "2019-02-01",
37+
* "2019-03-01",
38+
* "2019-04-01",
39+
* ]
40+
* const df = new Dataframe(data)
41+
* const dfNew = df.dt.month()
42+
* console.log(dfNew.values)
43+
* // [1, 2, 3, 4]
44+
* ```
45+
*/
46+
month(): Series;
47+
/**
48+
* Returns the day of the week, in local time
49+
* @example
50+
* ```
51+
* import { Dataframe } from "danfojs-node"
52+
* const data = [
53+
* "2019-01-01",
54+
* "2019-02-01",
55+
* "2019-03-01",
56+
* "2019-04-01",
57+
* ]
58+
* const df = new Dataframe(data)
59+
* const dayOfWeek = df.dt.day()
60+
* console.log(day.values)
61+
* ```
62+
*/
63+
day(): Series;
64+
/**
65+
* Returns the year, in local time
66+
* @example
67+
* ```
68+
* import { Dataframe } from "danfojs-node"
69+
* const data = [
70+
* "2019-01-01",
71+
* "2019-02-01",
72+
* "2021-03-01",
73+
* "2020-04-01",
74+
* ]
75+
* const df = new Dataframe(data)
76+
* const year = df.dt.year()
77+
* console.log(year.values)
78+
* // [2019, 2019, 2021, 2020]
79+
* ```
80+
*/
81+
year(): Series;
82+
/**
83+
* Returns the name of the month, in local time
84+
* @example
85+
* ```
86+
* import { Dataframe } from "danfojs-node"
87+
* const data = [
88+
* "2019-01-01",
89+
* "2019-02-01",
90+
* "2021-03-01",
91+
* "2020-04-01",
92+
* ]
93+
* const df = new Dataframe(data)
94+
* const monthName = df.dt.month_name().values
95+
* console.log(monthName)
96+
* // ["January", "February", "March", "April"]
97+
* ```
98+
*/
99+
month_name(): Series;
100+
/**
101+
* Returns the name of the day, of the week, in local time
102+
* @example
103+
* ```
104+
* import { Dataframe } from "danfojs-node"
105+
* const data = [
106+
* "2019-01-01",
107+
* "2019-02-01",
108+
* "2021-03-01",
109+
* "2020-04-01",
110+
* ]
111+
* const df = new Dataframe(data)
112+
* const dayOfWeekName = df.dt.weekdays().values
113+
* console.log(dayOfWeekName)
114+
* ```
115+
*/
116+
weekdays(): Series;
117+
/**
118+
* Returns the day of the month, in local time
119+
* @example
120+
* ```
121+
* import { Dataframe } from "danfojs-node"
122+
* const data = [
123+
* "2019-01-01",
124+
* "2019-02-05",
125+
* "2021-03-02",
126+
* "2020-04-01",
127+
* ]
128+
* const df = new Dataframe(data)
129+
* const dayOfMonth = df.dt.monthday().values
130+
* console.log(dayOfMonth)
131+
* // [1, 5, 2, 1]
132+
* ```
133+
*/
134+
monthday(): Series;
135+
/**
136+
* Returns the hour of the day, in local time
137+
* @example
138+
* ```
139+
* import { Dataframe } from "danfojs-node"
140+
* const data = [
141+
* "2019-01-01",
142+
* "2019-02-05",
143+
* "2021-03-02",
144+
* "2020-04-01",
145+
* ]
146+
* const df = new Dataframe(data)
147+
* const hour = df.dt.hour().values
148+
* console.log(hour)
149+
* // [0, 0, 0, 0]
150+
* ```
151+
*/
152+
hours(): Series;
153+
/**
154+
* Returns the second of the day, in local time
155+
* @example
156+
* ```
157+
* import { Dataframe } from "danfojs-node"
158+
* const data = [
159+
* "2019-01-01",
160+
* "2019-02-05",
161+
* "2021-03-02",
162+
* "2020-04-01",
163+
* ]
164+
* const df = new Dataframe(data)
165+
* const second = df.dt.second().values
166+
* console.log(second)
167+
* ```
168+
*/
169+
seconds(): Series;
170+
/**
171+
* Returns the minute of the day, in local time
172+
* @example
173+
* ```
174+
* import { Dataframe } from "danfojs-node"
175+
* const data = [
176+
* "2019-01-01",
177+
* "2019-02-05",
178+
* "2021-03-02",
179+
* "2020-04-01",
180+
* ]
181+
* const df = new Dataframe(data)
182+
* const minute = df.dt.minute().values
183+
* console.log(minute)
184+
* ```
185+
*/
186+
minutes(): Series;
187+
}
188+
export declare const toDateTime: (data: Series | ArrayType1D) => TimeSeries;

0 commit comments

Comments
 (0)