Java में डेटा क्लीनिंग
Dennis Lee
Software Engineer
| Books | Authors | Language | First_Published | Sales_in_Millions | Average_Price |
|---|---|---|---|---|---|
| A Tale of Two Cities | Charles Dickens | English | 1859 | 200.0 | 12.99 |
| The Little Prince (Le Petit Prince) | Antoine de Saint-Exupéry | French | 1943 | 200.0 | 15.50 |
| Harry Potter and the Philosopher's Stone | J. K. Rowling | English | 1997 | 120.0 | 19.99 |
| And Then There Were None | Agatha Christie | English | 1939 | 100.0 | 14.95 |
import tech.tablesaw.api.Table;
import tech.tablesaw.api.DoubleColumn;
import tech.tablesaw.api.StringColumn;
// CSV फ़ाइल को Tablesaw टेबल में लोड करें
Table books = Table.read().csv("bestsellers.csv");
// बुनियादी टेबल जानकारी: row count, column count, column names
System.out.println("Row count: " + books.rowCount());
System.out.println("Column count: " + books.columnCount());
System.out.println("Column names: " + books.columnNames());
Row count: 290
Column count: 6
Column names: [Books, Authors, Language, First_Published, Sales_in_millions]
for (String columnName : books.columnNames()) {// कॉलम नाम से कॉलम लें और उस कॉलम में missing values (nulls) गिनें int missing = books.column(columnName).countMissing();System.out.println(columnName + " missing values: " + missing); }
Books missing values: 0
Authors missing values: 0
Language missing values: 0
First_Published missing values: 0
Sales_in_millions missing values: 2
Average_Price missing values: 0
// countBy() यूनिक वैल्यू और उनकी फ़्रीक्वेंसी वाली नई टेबल बनाता है
Table languageCounts = books.countBy("Language");
System.out.println("Language distribution:\n");
// फ़ॉर्मैटेड टेबल प्रिंट करता है जिसमें हर language और उसकी count दिखती है
System.out.println(languageCounts);
Language distribution:
| Language | Count |
|------------|-------|
| English | 210 |
| French | 10 |
| Chinese | 6 |
| Portuguese | 1 |
| Spanish | 3 |
| German | 6 |
| Italian | 5 |
// सांख्यिकीय कार्यों के लिए numeric कॉलम को DoubleColumn के रूप में लें DoubleColumn sales = books.doubleColumn("Sales_in_millions");System.out.println("Sales Statistics (millions of copies):\n"); // कॉलम का सबसे छोटा मान System.out.println("Min sales: " + sales.min() + " million"); // कॉलम का सबसे बड़ा मान System.out.println("Max sales: " + sales.max() + " million");// सभी मानों का औसत System.out.println("Mean sales: " + sales.mean() + " million"); // फैलाव का माप (standard deviation) System.out.println("Std. deviation: " + sales.standardDeviation() + " million");
Sales Statistics (millions of copies):
Min sales: 10.0 million
Max sales: 600.0 million
Mean sales: 49.996875 million
Std. deviation: 64.6846320839116 million
System.out.printf("Rows: %d, Columns: %s", books.rowCount(), books.columnCount());
for (String colName : books.columnNames()) // हर कॉलम के लिए
System.out.println(books.column(colName).countMissing()); // null वैल्यू गिनें
StringColumn language = books.stringColumn("Language"); // टेक्स्ट कॉलम लें
Table langCounts = books.countBy("Language"); // श्रेणियाँ गिनें
// न्यूमेरिक आँकड़े निकालें
DoubleColumn sales = books.doubleColumn("Sales_in_Millions"); // संख्या कॉलम लें
System.out.printf("Mean: %.1f million, Min: %.1f million, Max: %.1f million",
sales.mean(), sales.min(), sales.max());
Rows: 290, Columns: 6
Books missing values: 0
Authors missing values: 0
| Language | Count |
|------------|-------|
| English | 210 |
| French | 10 |
Mean: 50.0 million, Min: 10.0 million, Max: 600.0 million
Java में डेटा क्लीनिंग