Data Science & Machine Learning
Join this channel to learn data science, artificial intelligence and machine learning with funny quizzes, interesting projects and amazing resources for free For collaborations: @love_data
Mostrar más📈 Análisis del canal de Telegram Data Science & Machine Learning
El canal Data Science & Machine Learning (@datasciencefun) en el segmento lingüístico de Inglés es un actor destacado. Actualmente la comunidad reúne a 77 285 suscriptores, ocupando la posición 2 004 en la categoría Educación y el puesto 4 033 en la región India.
📊 Métricas de audiencia y dinámica
Desde su creación el невідомо, el proyecto ha mostrado un crecimiento acelerado, reuniendo a 77 285 suscriptores.
Según los últimos datos del 27 agosto, 2026, el canal mantiene una actividad estable. En los últimos 30 días la variación de miembros fue de 372, y en las últimas 24 horas de 1, conservando un alto alcance.
- Estado de verificación: No verificado
- Tasa de interacción (ER): El promedio de interacción de la audiencia es 2.60%. Durante las primeras 24 horas tras publicar, el contenido suele obtener 1.12% de reacciones respecto al total de suscriptores.
- Alcance de las publicaciones: Cada publicación recibe en promedio 2 009 visualizaciones. En el primer día suele acumular 866 visualizaciones.
- Reacciones e interacción: La audiencia responde de forma activa: el promedio de reacciones por publicación es 3.
- Intereses temáticos: El contenido se centra en temas clave como learning, accuracy, distribution, panda, dataset.
📝 Descripción y política de contenido
El autor describe el recurso como un espacio para expresar opiniones subjetivas:
“Join this channel to learn data science, artificial intelligence and machine learning with funny quizzes, interesting projects and amazing resources for free
For collaborations: @love_data”
Gracias a la alta frecuencia de actualizaciones (últimos datos recibidos el 28 agosto, 2026), el canal mantiene la vigencia y un amplio alcance. La analítica demuestra que la audiencia interactúa activamente con el contenido, lo que lo convierte en un punto de referencia dentro de la categoría Educación.
with open("sample.txt", "r") as file:
print(file.read())
You don't need to call
close()manually. 🔹 11. Reading a File Line by Line
with open("sample.txt", "r") as file:
for line in file:
print(line.strip())
This is useful for processing large files efficiently.
🔹 12. Real-World Data Science Example
Suppose you have a text file containing sales data:
100
250
175
300
Python code:
total = 0
with open("sales.txt", "r") as file:
for line in file:
total += int(line)
print(total)
Output:
825In real-world projects, similar logic is used to process datasets before loading them into Pandas. 🔹 13. Common Mistakes ❌ Forgetting to Close the File
file = open("sample.txt", "r")
print(file.read())
Always use:
with open("sample.txt", "r") as file:
print(file.read())
❌ Opening a Non-Existent File
open("data.txt", "r")
If the file doesn't exist, Python raises a
FileNotFoundError. Always verify that the file exists or handle exceptions appropriately. 🎯 Practice Questions 1. Create your own Python module with two functions and import it into another file. 2. Import the "math" module and calculate the square root of 144. 3. Create a text file and write five lines into it. 4. Read a text file line by line using the "with" statement. 5. Read a file containing numbers and calculate their average. 🎯 Key Takeaways ✅ A module is a reusable Python file containing code. ✅ A package is a collection of related modules. ✅ Use "import" to access modules and their functions. ✅ Use "open()" to read and write files. ✅ Prefer the "with" statement because it automatically closes files. ✅ File handling is a fundamental skill for reading datasets, logs, configuration files, and other real-world data sources. Mastering modules, packages, and file handling will prepare you for working with Python libraries like Pandas, NumPy, and Scikit-learn, where data is frequently loaded from external files. Double Tap ❤️ For More
calculator.py
def add(a, b):
return a + b
def subtract(a, b):
return a - b
Now use it in another file:
import calculator
print(calculator.add(10, 5))
Output: 15
🔹 2. Importing Modules
Python provides different ways to import modules.
Import the Entire Module
import math
print(math.sqrt(25))
Output: 5.0
Import Specific Functions
from math import sqrt
print(sqrt(49))
Output: 7.0
Import with an Alias
Aliases make long module names easier to use.
import math as m
print(m.pi)
Output: 3.141592653589793
🔹 3. Common Built-in Modules
Some commonly used Python modules are:
• "math" → Mathematical operations
• "random" → Generate random numbers
• "datetime" → Work with dates and times
• "os" → Interact with the operating system
• "sys" → Access system-specific information
• "statistics" → Perform statistical calculations
Example:
import random
print(random.randint(1, 10))
This generates a random integer between 1 and 10.
🔹 4. What is a Package?
A package is a collection of related modules organized into folders.
Example:
project/
│
├── main.py
├── utilities/
│ ├── init.py
│ ├── calculator.py
│ └── helper.py
Packages help organize large Python projects into manageable sections.
🔹 5. File Handling
Most Data Science projects involve reading data from files such as:
• CSV files
• Text files
• Excel files
• JSON files
Python provides built-in functions for file handling.
🔹 6. Opening a File
Syntax: open(file_name, mode)
Common modes:
Mode | Description
"r" | Read
"w" | Write (overwrites existing content)
"a" | Append
"x" | Create a new file
"rb" | Read binary files
"wb" | Write binary files
🔹 7. Reading a File
Suppose sample.txt contains:
Welcome to Python
Learning File Handling
Python code:
file = open("sample.txt", "r")
print(file.read())
file.close()
Output:
Welcome to Python
Learning File Handling
🔹 8. Writing to a File
file = open("sample.txt", "w")
file.write("Hello Data Science!")
file.close()
This replaces the previous contents of the file.
🔹 9. Appending to a File
file = open("sample.txt", "a")
file.write("\nPython is awesome!")
file.close()[20, 40, 60]First, filter() keeps only even numbers. Then, map() multiplies each by 10. 🔹 11. Common Mistakes ❌ Forgetting to Convert map() to a List
result = map(lambda x: x * 2, numbers)
→
<map object at ...>Correct:
print(list(result))
❌ Forgetting to Import reduce()
result = reduce(lambda a, b: a + b, [1, 2, 3])→
NameErrorCorrect:
from functools import reduce
🎯 Practice Questions
1. Create a lambda function that returns the cube of a number.
2. Use map() to convert a list of temperatures from Celsius to Fahrenheit.
3. Use filter() to find numbers greater than 50.
4. Use reduce() to calculate the product of a list of numbers.
5. Combine filter() and map() to square only the odd numbers in a list.
🎯 Key Takeaways
✅ Lambda functions are short, anonymous functions.
✅ map() transforms every element in an iterable.
✅ filter() selects elements based on a condition.
✅ reduce() combines all elements into a single value.
✅ These functions are widely used for data transformation, preprocessing, and feature engineering in Data Science.
Double Tap ❤️ For Morelambda arguments: expression
Example
square = lambda x: x * x
print(square(5))
Output: 25
This is equivalent to:
def square(x):
return x * x
🔹 2. Why Use Lambda Functions?
Lambda functions are useful when:
✅ You need a simple function only once.
✅ You want shorter, cleaner code.
✅ You're using functions like map(), filter(), or sorted().
🔹 3. Lambda with Multiple Arguments
add = lambda a, b: a + b
print(add(10, 20))
Output: 30
🔹 4. The map() Function
The map() function applies a function to every item in an iterable.
Syntax: map(function, iterable)
Example
numbers = [1, 2, 3, 4, 5]
squares = list(map(lambda x: x ** 2, numbers))
print(squares)
Output: [1, 4, 9, 16, 25]
🔹 5. Using map() with a Normal Function
def double(x):
return x * 2
numbers = [1, 2, 3, 4]
result = list(map(double, numbers))
print(result)
Output: [2, 4, 6, 8]
🔹 6. The filter() Function
The filter() function selects only those elements that satisfy a condition.
Syntax: filter(function, iterable)
Example
numbers = [1, 2, 3, 4, 5, 6]
even = list(filter(lambda x: x % 2 == 0, numbers))
print(even)
Output: [2, 4, 6]
🔹 7. The reduce() Function
The reduce() function applies a function repeatedly to reduce an iterable to a single value.
It is available in the functools module.
from functools import reduce
numbers = [1, 2, 3, 4]
result = reduce(lambda a, b: a + b, numbers)
print(result)
Output: 10
🔹 8. Difference Between map(), filter(), and reduce()
map(): Transforms every element in an iterable and returns a new iterable.
filter(): Keeps only elements that match a condition and returns a filtered iterable.
reduce(): Combines all elements into a single value.
🔹 9. Real-World Data Science Example
Suppose you have customer purchase amounts.
purchases = [1200, 450, 1800, 900, 2500]
high_value = list(filter(lambda x: x > 1000, purchases))
print(high_value)
Output: [1200, 1800, 2500]
Now calculate the total revenue.
from functools import reduce
total = reduce(lambda a, b: a + b, purchases)
print(total)
Output: 6850
🔹 10. Combining map() and filter()
numbers = [1, 2, 3, 4, 5, 6]
result = list(
map(
lambda x: x * 10,
filter(lambda x: x % 2 == 0, numbers)
)
)
print(result)[1200, 1500, 2000]
This technique is commonly used while cleaning and filtering datasets before analysis.
🔹 10. Benefits of List Comprehensions
✅ Shorter code
✅ Easier to read
✅ Faster than traditional loops in many cases
✅ Widely used in Data Science and Machine Learning
🔹 11. Common Mistakes
❌ Forgetting the Expression
numbers = [for i in range(5)] # SyntaxError
Correct:
numbers = [i for i in range(5)]
❌ Incorrect Order of "if"
numbers = [if x % 2 == 0 x for x in range(10)]
Correct:
numbers = [x for x in range(10) if x % 2 == 0]
🎯 Practice Questions
1. Create a list of numbers from 1 to 20.
2. Create a list containing the squares of numbers from 1 to 10.
3. Create a list containing only odd numbers from 1 to 20.
4. Convert a list of names to lowercase.
5. Replace all negative values in a list with zero using a list comprehension.
🎯 Key Takeaways
✅ List comprehensions provide a concise way to create lists.
✅ They combine loops and expressions into a single line.
✅ You can filter data using "if" conditions.
✅ Conditional expressions allow values to be modified during list creation.
✅ List comprehensions are widely used in data cleaning, feature engineering, and machine learning workflows.
Mastering list comprehensions will help you write cleaner, more Pythonic code and prepare you for technical interviews and real-world Data Science projects.
Double Tap ❤️ For Part-9
-----
1.25 ₽ · /balance_helpnew_list = [expression for item in iterable]
🔹 2. Creating a List Using a Loop
numbers = []
for i in range(5):
numbers.append(i)
print(numbers)
Output
[0, 1, 2, 3, 4]
🔹 3. Creating the Same List Using List Comprehension
numbers = [i for i in range(5)]
print(numbers)
Output
[0, 1, 2, 3, 4]
Notice how the code is shorter and easier to read.
🔹 4. Performing Calculations
Create a list of squares.
squares = [x ** 2 for x in range(1, 6)]
print(squares)
Output
[1, 4, 9, 16, 25]
🔹 5. Using Conditions
You can filter elements while creating a list.
Example: Even Numbers
even_numbers = [x for x in range(1, 11) if x % 2 == 0]
print(even_numbers)
Output
[2, 4, 6, 8, 10]
🔹 6. Converting Strings
Convert all names to uppercase.
names = ["rahul", "deepak", "anita"]
upper_names = [name.upper() for name in names]
print(upper_names)
Output
['RAHUL', 'DEEPAK', 'ANITA']
🔹 7. Using Conditional Expressions
Replace negative numbers with zero.
numbers = [5, -2, 8, -1, 3]
updated = [0 if x < 0 else x for x in numbers]
print(updated)
Output
[5, 0, 8, 0, 3]
🔹 8. Nested List Comprehension
Create a multiplication table.
table = [[i * j for j in range(1, 6)] for i in range(1, 4)]
print(table)
Output
[[1, 2, 3, 4, 5],
[2, 4, 6, 8, 10],
[3, 6, 9, 12, 15]]
🔹 9. Real-World Data Science Example
Suppose you have a list of sales amounts.
sales = [1200, 850, 1500, 600, 2000]
high_sales = [sale for sale in sales if sale > 1000]
print(high_sales)