Skip to content

Commit d3f814d

Browse files
committed
Update plot type and set default typing config in IO
1 parent b523a7b commit d3f814d

File tree

17 files changed

+1275
-484
lines changed

17 files changed

+1275
-484
lines changed

danfojs-browser/.eslintrc.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,11 @@
2323
"before": false, "after": true
2424
}
2525
],
26-
"indent": [ "error",
27-
2
28-
],
2926
"keyword-spacing": [
3027
"error",
3128
{ "before": true
3229
}
3330
],
34-
"array-bracket-spacing": [ "error", "always"
35-
],
3631
"space-infix-ops": "error",
3732
"object-curly-spacing": [ "error", "always"
3833
],

danfojs-browser/README.md

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ To use Danfo.js via script tags, copy and paste the CDN below to the body of you
8686
8787
df.plot("div2").table() //display csv as table
8888
89-
new_df = df.set_index({ key: "Date" }) //resets the index to Date column
89+
new_df = df.set_index({ column: "Date" }) //resets the index to Date column
9090
new_df.plot("div3").line({ columns: ["AAPL.Open", "AAPL.High"] }) //makes a timeseries plot
9191
9292
}).catch(err => {
@@ -117,59 +117,61 @@ npm install danfojs-node
117117

118118
const dfd = require("danfojs-node")
119119

120+
const file_url = "https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv"
121+
dfd.read_csv(file_url)
122+
.then(df => {
123+
//prints the first five columns
124+
df.head().print()
120125

121-
dfd.read_csv("https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv")
122-
.then(df => {
123-
//prints the first five columns
124-
df.head().print()
126+
// Calculate descriptive statistics for all numerical columns
127+
df.describe().print()
125128

126-
//Calculate descriptive statistics for all numerical columns
127-
df.describe().print()
129+
//prints the shape of the data
130+
console.log(df.shape);
128131

129-
//prints the shape of the data
130-
console.log(df.shape);
132+
//prints all column names
133+
console.log(df.columns);
131134

132-
//prints all column names
133-
console.log(df.column_names);
135+
// //prints the inferred dtypes of each column
136+
df.ctypes.print()
134137

135-
//prints the inferred dtypes of each column
136-
df.ctypes.print()
138+
//selecting a column by subsetting
139+
df['Name'].print()
137140

138-
//selecting a column by subsetting
139-
df['Name'].print()
141+
//drop columns by names
142+
cols_2_remove = ['Age', 'Pclass']
143+
df_drop = df.drop({ columns: cols_2_remove, axis: 1 })
144+
df_drop.print()
140145

141-
//drop columns by names
142-
cols_2_remove = ['Age', 'Pclass']
143-
df_drop = df.drop({ columns: cols_2_remove, axis: 1 })
144-
df_drop.print()
145146

147+
//select columns by dtypes
148+
let str_cols = df_drop.select_dtypes(["string"])
149+
let num_cols = df_drop.select_dtypes(["int32", "float32"])
150+
str_cols.print()
151+
num_cols.print()
146152

147-
//select columns by dtypes
148-
let str_cols = df_drop.select_dtypes(["string"])
149-
let num_cols = df_drop.select_dtypes(["int32", "float32"])
150-
str_cols.print()
151-
num_cols.print()
152153

154+
//add new column to Dataframe
153155

154-
//add new column to Dataframe
155-
let new_vals = df['Fare'].round().values
156-
df_drop.addColumn({ column: "fare_round", value: new_vals})
157-
df_drop.print()
156+
let new_vals = df['Fare'].round(1)
157+
df_drop.addColumn({ column: "fare_round", values: new_vals, inplace: true })
158+
df_drop.print()
158159

159-
df_drop['fare_round'].print(5)
160+
df_drop['fare_round'].round(2).print(5)
160161

161-
//prints the number of occurence each value in the column
162-
df_drop['Survived'].value_counts().print()
162+
//prints the number of occurence each value in the column
163+
df_drop['Survived'].value_counts().print()
163164

164-
//print the last ten elementa of a DataFrame
165-
df_drop.tail(10).print()
165+
//print the last ten elementa of a DataFrame
166+
df_drop.tail(10).print()
166167

167-
//prints the number of missing values in a DataFrame
168-
df_drop.isna().sum().print()
168+
//prints the number of missing values in a DataFrame
169+
df_drop.isna().sum().print()
170+
171+
}).catch(err => {
172+
console.log(err);
173+
})
169174

170-
}).catch(err => {
171-
console.log(err);
172-
})
173175

174176
```
175177
Output in Node Console:

0 commit comments

Comments
 (0)