@@ -70,14 +70,15 @@ yarn add danfojs
7070For use directly in HTML files, you can add the latest script tag from [ JsDelivr] ( https://www.jsdelivr.com/package/npm/danfojs ) to your HTML file:
7171
7272``` html
73- <script src =" https://cdn.jsdelivr.net/npm/danfojs@1.1.0 /lib/bundle.js" ></script >
73+ <script src =" https://cdn.jsdelivr.net/npm/danfojs@1.1.1 /lib/bundle.js" ></script >
7474```
7575See all available versions [ here] ( https://www.jsdelivr.com/package/npm/danfojs )
7676
7777### Quick Examples
7878* [ Danfojs with HTML and vanilla JavaScript on CodePen] ( https://codepen.io/risingodegua/pen/bGpwyYW )
7979* [ Danfojs with React on Code Sandbox] ( https://codesandbox.io/s/using-danfojs-in-react-dwpv54?file=/src/App.js )
8080* [ Danfojs on ObservableHq] ( https://observablehq.com/@risingodegua/using-danfojs-on-observablehq )
81+ * [ Danfojs in Nodejs on Replit] ( https://replit.com/@RisingOdegua/Danfojs-in-Nodejs )
8182
8283### Example Usage in the Browser
8384``` html
@@ -87,7 +88,7 @@ See all available versions [here](https://www.jsdelivr.com/package/npm/danfojs)
8788 <head >
8889 <meta charset =" UTF-8" />
8990 <meta name =" viewport" content =" width=device-width, initial-scale=1.0" />
90- <script src =" https://cdn.jsdelivr.net/npm/danfojs@1.1.0 /lib/bundle.js" ></script >
91+ <script src =" https://cdn.jsdelivr.net/npm/danfojs@1.1.1 /lib/bundle.js" ></script >
9192
9293 <title >Document</title >
9394 </head >
@@ -130,69 +131,62 @@ Output in Browser:
130131### Example usage in Nodejs
131132
132133``` javascript
134+ const dfd = require (" danfojs-node" );
133135
134- const dfd = require (" danfojs-node" )
136+ const file_url =
137+ " https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv" ;
138+ dfd
139+ .readCSV (file_url)
140+ .then ((df ) => {
141+ // prints the first five columns
142+ df .head ().print ();
135143
136- const file_url = " https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv"
137- dfd .readCSV (file_url)
138- .then (df => {
139- // prints the first five columns
140- df .head ().print ()
144+ // Calculate descriptive statistics for all numerical columns
145+ df .describe ().print ();
141146
142- // Calculate descriptive statistics for all numerical columns
143- df . describe (). print ()
147+ // prints the shape of the data
148+ console . log ( df . shape );
144149
145- // prints the shape of the data
146- console .log (df .shape );
150+ // prints all column names
151+ console .log (df .columns );
147152
148- // prints all column names
149- console . log ( df .columns );
153+ // //prints the inferred dtypes of each column
154+ df .ctypes . print ( );
150155
151- // //prints the inferred dtypes of each column
152- df . ctypes . print ()
156+ // selecting a column by subsetting
157+ df[ " Name " ]. print ();
153158
154- // selecting a column by subsetting
155- df[' Name' ].print ()
159+ // drop columns by names
160+ let cols_2_remove = [" Age" , " Pclass" ];
161+ let df_drop = df .drop ({ columns: cols_2_remove, axis: 1 });
162+ df_drop .print ();
156163
157- // drop columns by names
158- cols_2_remove = [' Age' , ' Pclass' ]
159- df_drop = df .drop ({ columns: cols_2_remove, axis: 1 })
160- df_drop .print ()
164+ // select columns by dtypes
165+ let str_cols = df_drop .selectDtypes ([" string" ]);
166+ let num_cols = df_drop .selectDtypes ([" int32" , " float32" ]);
167+ str_cols .print ();
168+ num_cols .print ();
161169
170+ // add new column to Dataframe
162171
163- // select columns by dtypes
164- let str_cols = df_drop .selectDtypes ([" string" ])
165- let num_cols = df_drop .selectDtypes ([" int32" , " float32" ])
166- str_cols .print ()
167- num_cols .print ()
172+ let new_vals = df[" Fare" ].round (1 );
173+ df_drop .addColumn (" fare_round" , new_vals, { inplace: true });
174+ df_drop .print ();
168175
169- // select columns by dtypes
170- let str_cols = df_drop .select_dtypes ([" string" ])
171- let num_cols = df_drop .select_dtypes ([" int32" , " float32" ])
172- str_cols .print ()
173- num_cols .print ()
176+ df_drop[" fare_round" ].round (2 ).print (5 );
174177
175- // add new column to Dataframe
178+ // prints the number of occurence each value in the column
179+ df_drop[" Survived" ].valueCounts ().print ();
176180
177- let new_vals = df[' Fare' ].round (1 )
178- df_drop .addColumn (" fare_round" , new_vals, { inplace: true })
179- df_drop .print ()
180-
181- df_drop[' fare_round' ].round (2 ).print (5 )
182-
183- // prints the number of occurence each value in the column
184- df_drop[' Survived' ].valueCounts ().print ()
185-
186- // print the last ten elementa of a DataFrame
187- df_drop .tail (10 ).print ()
188-
189- // prints the number of missing values in a DataFrame
190- df_drop .isNa ().sum ().print ()
191-
192- }).catch (err => {
193- console .log (err);
194- })
181+ // print the last ten elementa of a DataFrame
182+ df_drop .tail (10 ).print ();
195183
184+ // prints the number of missing values in a DataFrame
185+ df_drop .isNa ().sum ().print ();
186+ })
187+ .catch ((err ) => {
188+ console .log (err);
189+ });
196190
197191```
198192Output in Node Console:
0 commit comments