# PySpark function that is used to convert angle measures from degrees to radians.

Within its extensive library of functions, radians plays a crucial role for users dealing with trigonometric operations. The radians function in PySpark is used to convert angle measures from degrees to radians. This conversion is essential in various scientific calculations, especially in fields involving geometry or physics. This article provides an in-depth look at the radians function, enhanced by a practical example.

### Syntax:

from pyspark.sql.functions import radians
df.withColumn("radians_column", radians(df["degrees_column"]))

### Example

Consider a scenario where we have a dataset containing angles in degrees, and we need to convert these angles to radians for further trigonometric calculations.

### Sample data

Suppose we have the following data in a DataFrame named angles_df:

AngleName Degrees
Angle A 30
Angle B 45
Angle C 60
Angle D 90
Angle E 180

### Code implementation

from pyspark.sql import SparkSession
from pyspark.sql.types import *
# Initialize Spark Session
spark = SparkSession.builder.appName("Radians Example at Freshers.in").getOrCreate()
# Sample data
data = [("Angle A", 30),
("Angle B", 45),
("Angle C", 60),
("Angle D", 90),
("Angle E", 180)]
# Define schema
schema = StructType([
StructField("AngleName", StringType(), True),
StructField("Degrees", IntegerType(), True)
])
# Create DataFrame
angles_df = spark.createDataFrame(data, schema)
# Show results


The resulting DataFrame will include the original angles in degrees alongside a new column, Radians, displaying the converted values in radians. This conversion facilitates further trigonometric analysis.

+---------+-------+------------------+