Skip to content

Commit f2d4d19

Browse files
committed
Add/Update Typescript types for new features
1 parent e4adde7 commit f2d4d19

26 files changed

Lines changed: 2724 additions & 1069 deletions

danfojs-node/src/core/datetime.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ export default class TimeSeries {
7474
* "2019-04-01",
7575
* ]
7676
* const df = new Dataframe(data)
77-
* const dayOfWeek = df.dt.dayOfWeek()
78-
* console.log(dayOfWeek.values)
77+
* const dayOfWeek = df.dt.day()
78+
* console.log(day.values)
7979
* ```
8080
*/
8181
day() {

danfojs-node/src/core/series.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ export default class Series extends NDframe {
980980
*/
981981
argsort(ascending = true) {
982982
const sortedIndex = this.sort_values(ascending);
983-
const sf = new Series(sortedIndex?.index);
983+
const sf = new Series(sortedIndex.index);
984984
return sf;
985985
}
986986

@@ -1347,9 +1347,9 @@ export default class Series extends NDframe {
13471347
* - `prefixSeparator`: Separator to use for the prefix. Defaults to '_'.
13481348
* @returns A DataFrame with the one-hot encoded columns.
13491349
* @example
1350-
* sf.getDummies()
1351-
* sf.getDummies({prefix: 'cat' })
1352-
* sf.getDummies({ prefix: 'cat', prefixSeparator: '-' })
1350+
* sf.get_dummies()
1351+
* sf.get_dummies({prefix: 'cat' })
1352+
* sf.get_dummies({ prefix: 'cat', prefixSeparator: '-' })
13531353
*/
13541354
get_dummies(options) {
13551355
return dummyEncode(this, options);

danfojs-node/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)