Machine Learning
39.2K subscribers
3.83K photos
32 videos
42 files
1.3K links
Machine learning insights, practical tutorials, and clear explanations for beginners and aspiring data scientists. Follow the channel for models, algorithms, coding guides, and real-world ML applications.

Admin: @HusseinSheikho || @Hussein_Sheikho
Download Telegram
• Group data by a column.
df.groupby('col1')

• Group by a column and get the sum.
df.groupby('col1').sum()

• Apply multiple aggregation functions at once.
df.groupby('col1').agg(['mean', 'count'])

• Get the size of each group.
df.groupby('col1').size()

• Get the frequency counts of unique values in a Series.
df['col1'].value_counts()

• Create a pivot table.
pd.pivot_table(df, values='D', index=['A', 'B'], columns=['C'])


VI. Merging, Joining & Concatenating

• Merge two DataFrames (like a SQL join).
pd.merge(left_df, right_df, on='key_column')

• Concatenate (stack) DataFrames along an axis.
pd.concat([df1, df2]) # Stacks rows

• Join DataFrames on their indexes.
left_df.join(right_df, how='outer')


VII. Input & Output

• Write a DataFrame to a CSV file.
df.to_csv('output.csv', index=False)

• Write a DataFrame to an Excel file.
df.to_excel('output.xlsx', sheet_name='Sheet1')

• Read data from an Excel file.
pd.read_excel('input.xlsx', sheet_name='Sheet1')

• Read from a SQL database.
pd.read_sql_query('SELECT * FROM my_table', connection_object)


VIII. Time Series & Special Operations

• Use the string accessor (.str) for Series operations.
s.str.lower()
s.str.contains('pattern')

• Use the datetime accessor (.dt) for Series operations.
s.dt.year
s.dt.day_name()

• Create a rolling window calculation.
df['col1'].rolling(window=3).mean()

• Create a basic plot from a Series or DataFrame.
df['col1'].plot(kind='hist')


#Python #Pandas #DataAnalysis #DataScience #Programming

━━━━━━━━━━━━━━━
By: @DataScienceM
6👍1🔥1
📌 How to Implement Randomization with the Python Random Module

🗂 Category: PROGRAMMING

🕒 Date: 2025-11-24 | ⏱️ Read time: 6 min read

Master Python's built-in random module to introduce unpredictability into your applications. This guide explores how to effectively generate random outputs, a crucial technique for tasks ranging from shuffling data and creating simulations to developing games and selecting random samples. Learn the core functions and practical implementations to leverage randomization in your code.

#Python #Programming #CodingTips #Random
3
📌 How to Generate QR Codes in Python

🗂 Category: PROGRAMMING

🕒 Date: 2025-12-02 | ⏱️ Read time: 7 min read

Unlock the ability to generate QR codes with Python. This beginner-friendly tutorial provides a step-by-step guide to using the popular "qrcode" package. Learn how to easily create and customize QR codes for your applications, from encoding URLs to embedding custom data.

#Python #QRCode #Programming #PythonTutorial
4