Skip to main content

Posts

Showing posts with the label Bigdata

PySpark | How To Handle Nulls In DataFrame?

Handling NULL (or None) values is a crucial task in data processing,  as missing data can skew analysis, produce errors in data transformations,  and degrade the performance of machine learning models.  In PySpark, dealing with NULL values is a common operation when working with distributed  datasets. PySpark provides several methods and techniques to detect, manage, and clean up  missing or NULL values in a DataFrame. In this blog post, we’ll explore how to handle NULL values in PySpark DataFrames, covering  essential methods like filtering, filling, dropping, and replacing NULL values. Methods to Handle NULL Values in PySpark: PySpark provides several ways to manage NULL values effectively: Detecting NULLs: Identifying rows or columns with NULL values. Filtering: Excluding NULL values from the DataFrame. Dropping: Removing rows or columns with NULL values. Filling: Replacing NULL values with a specific value. Replacing: Substituting NULL values based on c...

How to remove duplicates from data?

Removing Duplicates from Production Data in Real-Time Using SQL Handling duplicates in production data requires efficient strategies to maintain data integrity and avoid system performance issues. Here’s a structured approach to achieve this:   --- ### **1. Prevention: Use Unique Constraints**   The best way to deal with duplicates is to prevent them. Ensure your database schema is designed to enforce uniqueness:   - **Primary Key**: Define a primary key to prevent identical rows.   - **Unique Constraints**: Apply unique constraints to columns or combinations of columns that should not contain duplicate values.   **Example:**   ```sql ALTER TABLE my_table  ADD CONSTRAINT unique_constraint_name UNIQUE (column1, column2); ``` --- ### **2. Identifying Duplicates**   Before removing duplicates, identify them using `GROUP BY` and `HAVING`:   **Example:**   ```sql SELECT column1, column2, COUNT(*) AS duplicate_count FROM my_table GROUP BY colu...

How write operation done in HDFS?

How write operation done in HDFS?  HDFS follows Write once Read many model, s o we can't edit files which are already present in HDFS. Syntax to write data in HDFS:  hdfs dfs -put <local/file/path> <HDFS/location/where file needs to write>  exmple:         hdfs dfs -put /home/prajjwal/file1.txt  /landing_location/ To write a file in HDFS, a client needs to interact with master i.e. namenode (master). Namenode provides the address of the datanodes (slaves) on which client will start writing the data. Client can directly write data on the datanodes, now datanode will create data write pipeline. The first D ataNode will copy the block to another datanode, which intern copy it to the third datanode. Once it creates the replicas of blocks, it sends back the acknowledgment. We can understand with the help of below cartoon diagram. Thanks All.