डेटा ट्रांसफॉर्मेशन पैटर्न

Java में डेटा इम्पोर्ट करना

Anthony Markham

VP Quant Developer

Map फंक्शन

  • एक कॉलम के हर एलिमेंट को ट्रांसफॉर्म करता है
DoubleColumn celsius = DoubleColumn.create("Celsius", 0, 10, 20, 30);

DoubleColumn fahrenheit = celsius.map(c -> c * 9.0/5.0 + 32); table.addColumns(fahrenheit.setName("Fahrenheit"));
Celsius Fahrenheit
0.0 32.0
10.0 50.0
20.0 68.0
30.0 86.0
Java में डेटा इम्पोर्ट करना

Reduce फंक्शन

  • एक कॉलम के सभी मानों को मिलाकर एक परिणाम बनाता है
  • एक accumulator पैटर्न लागू करता है (जैसे sum, max, या कस्टम लॉजिक)
  • सांख्यिकीय और विश्लेषणात्मक ऑपरेशनों में उपयोगी
// Find the total sales
double totalSales = table.doubleColumn("Sales").reduce(0, Double::sum);
250000
// Find the maximum
double largeSales = table.doubleColumn("Sales").reduce(0, (acc, x) -> acc + (x > 5000 ? 1 : 0));
68
Java में डेटा इम्पोर्ट करना

forEach के साथ रो iteration

  • टेबल की हर रो पर iterate करता है
DoubleColumn difference = DoubleColumn.create("Difference");
table.forEach(row -> {
    double celsius = row.getDouble("Celsius");
    double fahrenheit = row.getDouble("Fahrenheit");
    difference.append(fahrenheit - celsius);
});

table.addColumns(difference);
Celsius Fahrenheit Difference
0.0 32.0 32.0
10.0 50.0 40.0
20.0 68.0 48.0
Java में डेटा इम्पोर्ट करना

ट्रांसफॉर्मेशन पाइपलाइन्स

  • कई ऑपरेशनों को चेन करें
  • हमारे कोड की readability और maintainability बढ़ाएँ ✅
  • प्रभावी डेटा प्रोसेसिंग ✅
Table result = originalTable
    .where(numberColumn("Age").isGreaterThan(18)) // Filter on Age > 18

.addColumns( numberColumn("Income").map(i -> i * 1.1).setName("AdjustedIncome") );
// Calculate average income double avgIncome = result.doubleColumn("AdjustedIncome") .reduce(0.0, Double::sum) / result.rowCount();
Java में डेटा इम्पोर्ट करना

रिकैप

  • map() - कॉलम मानों को बदलने के लिए फंक्शन लागू करें
  • forEach() - कई कॉलम एक्सेस करने के लिए रो पर iterate करें
  • reduce() - डेटा को एकल मानों में aggregate और summarize करें

तीन डेटा ट्रांसफॉर्मेशन फंक्शनों को दिखाती हुई छवि

Java में डेटा इम्पोर्ट करना

अभ्यास करते हैं!

Java में डेटा इम्पोर्ट करना

Preparing Video For Download...