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.selection.Selection;
Table books = Table.read().csv("bestsellers.csv"); // 70M से अधिक बिक्री वाली किताबों की शर्त Selection highSales = books.intColumn("Sales_in_Millions").isGreaterThan(70);// अंग्रेज़ी में लिखी किताबों की शर्त Selection english = books.stringColumn("Language").isEqualTo("English");// 1950 के बाद प्रकाशित किताबों की शर्त Selection recentlyPublished = books.intColumn("First_Published").isGreaterThan(1950);// समान: .isLessThan(), .isLessThanOrEqualTo(), .isGreaterThanOrEqualTo()
// एकल शर्त से सीधे फ़िल्टर करें books.where(books.intColumn("Sales_in_Millions").isGreaterThan(70));// पहले से परिभाषित Selection से फ़िल्टर करें books.where(highSales);// कई शर्तें .and() से जोड़ें Table popular = books.where(highSales) // Sales > 70M .and(english) // English language .and(recentlyPublished); // After 1950 .sortDescendingOn("Sales_in_Millions"); // Sort by Sales_in_Millions System.out.println("Modern high-revenue English books:\n"); System.out.println(modern.select("Books", "First_Published", "Total_Revenue"));
Modern high-revenue English books:
| Book | Sales_in_Millions | First_Published |
|------------------------------------------|-------------------|-----------------|
| Harry Potter and the Philosopher's Stone | 120 | 1997 |
| The Da Vinci Code | 80 | 2003 |
| Harry Potter and the Chamber of Secrets | 77 | 1998 |
// mean कैलकुलेशन फंक्शन इम्पोर्ट करें
import static tech.tablesaw.aggregate.AggregateFunctions.mean;
Table overallMean = books.summarize("Sales_in_Millions", mean).apply();
System.out.println("\nOverall mean sales: \n" + overallMean);
Overall mean sales:
| Mean [Sales_in_Millions] |
|---------------------------|
| 73.03225806451614 |
// हर भाषा समूह (जैसे English, French) के लिए औसत बिक्री निकालें Table salesByLanguage = books.summarize("Sales_in_Millions", mean) // means निकालें.by("Language"); // भाषा के आधार पर विभाजित करें // पहले 5 भाषा समूह दिखाएँ System.out.println("Average sales by language:\n"); System.out.println(salesByLanguage.first(5));
Average sales by language:
| Language | Mean [Sales_in_Millions] |
|------------|--------------------------|
| English | 69.96 |
| French | 200.0 |
| Chinese | 100.0 |
| Portuguese | 65.0 |
| Spanish | 50.0 |
import static tech.tablesaw.aggregate.AggregateFunctions.sum;
// भाषा के अनुसार फ़िल्टर और सारांश Table bestsellersByLanguage = books // 1950 के बाद की किताबें चुनें .where(books.intColumn("First_Published").isGreaterThan(1950))// कुल बिक्री निकालें .summarize("Sales_in_Millions", sum)// नतीजों को भाषा के हिसाब से ग्रुप करें .by("Language"); System.out.println("Modern bestsellers (post-1950) by language:\n"); System.out.println(bestsellersByLanguage);
Modern bestsellers (post-1950) by language:
| Language | Sum [Sales_in_Millions] |
|------------|-------------------------|
| English | 1071 |
| Portuguese | 65 |
| Spanish | 50 |
| Italian | 50 |
books.where(sales.isGreaterThan(150)); // एक शर्त के साथ बेसिक फ़िल्टरिंग
books.where(highSales.and(english)); // कई शर्तें - .and() से जोड़ें
// बेसिक एग्रीगेशन
books.summarize("Sales_in_Millions", mean) // means कैलकुलेट करें
.by("Language"); // भाषा के अनुसार ग्रुप करें
// संयुक्त ऑपरेशंस
books.where(books.intColumn("First_Published").isGreaterThan(1950)) // पहले फ़िल्टर
.summarize("Sales_in_Millions", mean) // फिर सारांश
.by("Language"); // अंत में ग्रुप
Java में डेटा क्लीनिंग