Python for Data Analysts
48.1K subscribers
504 photos
64 files
320 links
Find top Python resources from global universities, cool projects, and learning materials for data analytics.

For promotions: @coderfun

Useful links: heylink.me/DataAnalytics
Download Telegram
5 Pandas Functions to Handle Missing Data

🔹 fillna() – Fill missing values with a specific value or method
🔹 interpolate() – Fill NaNs with interpolated values (e.g., linear, time-based)
🔹 ffill() – Forward-fill missing values with the previous valid entry
🔹 bfill() – Backward-fill missing values with the next valid entry
🔹 dropna() – Remove rows or columns with missing values

#Pandas
👍11🥰1
Pandas Functions
👍7
Python Roadmap 🔝💪
4👍4
Data Cleaning Techniques in Python
👍9
Frequently asked Python practice questions and answers in Data Analyst Interview:
1.Temperature Conversion: Write a program that converts a given temperature from Celsius to Fahrenheit or from Fahrenheit to Celsius based on user input.
temp = float(input('Enter the temperature: '))
unit = input('Enter the unit (C/F): ').upper()
if unit == 'C':
converted = (temp * 9/5) + 32
print(f'Temperature in Fahrenheit: {converted}')
elif unit == 'F':
converted = (temp - 32) * 5/9
print(f'Temperature in Celsius: {converted}')
else:
print('Invalid unit')

2.Multiplication Table: Write a program that prints the multiplication table of a given number using a while loop.
num = int(input('Enter a number: '))
i = 1
while i <= 10:
print(f'{num} x {i} = {num * i}')
i += 1

3.Greatest of Three Numbers: Write a program that takes three numbers as input and prints the greatest of the three.
num1 = float(input('Enter first number: '))
num2 = float(input('Enter second number: '))
num3 = float(input('Enter third number: '))
if num1 >= num2 and num1 >= num3:
print(f'The greatest number is {num1}')
elif num2 >= num1 and num2 >= num3:
print(f'The greatest number is {num2}')
else:
print(f'The greatest number is {num3}')

4.Sum of Even Numbers: Write a program that calculates the sum of all even numbers between 1 and a given number using a while loop.
num = int(input('Enter a number: '))
total = 0
i = 2
while i <= num:
total += i
i += 2
print(f'The sum of even numbers up to {num} is {total}')

5.Check Armstrong Number: Write a program that checks if a given number is an Armstrong number.
num = int(input('Enter a number: '))
sum_of_digits = 0
original_num = num
while num > 0:
digit = num % 10
sum_of_digits += digit ** 3
num //= 10
if sum_of_digits == original_num:
print(f'{original_num} is an Armstrong number')
else:
print(f'{original_num} is not an Armstrong number')

6.Reverse a Number: Write a program that reverses the digits of a given number using a while loop.
num = int(input('Enter a number: '))
reversed_num = 0
while num > 0:
digit = num % 10
reversed_num = reversed_num * 10 + digit
num //= 10
print(f'The reversed number is {reversed_num}')

7.Count Vowels and Consonants: Write a program that counts the number of vowels and consonants in a given string.
string = input('Enter a string: ').lower()
vowels = 'aeiou'
vowel_count = 0
consonant_count = 0
for char in string:
if char.isalpha():
if char in vowels:
vowel_count += 1
else:
consonant_count += 1
print(f'Number of vowels: {vowel_count}')
print(f'Number of consonants: {consonant_count}')

Python Interview Q&A: https://topmate.io/coding/898340

Like for more ❤️

ENJOY LEARNING 👍👍
👍83
👉 List comprehensions: List comprehension offers a shorter syntax when you want to create a new list based on the values of an existing list.

Example:
Based on a list of fruits, you want a new list, containing only the fruits with the letter "a" in the name.
Without list comprehension you will have to write a for statement with a conditional test inside:

fruits = ["apple", "banana", "cherry", "kiwi", "mango"]
newlist = []

for x in fruits:
  if "a" in x:
    newlist.append(x)

print(newlist)

With list comprehension you can do all that with only one line of code:

fruits = ["apple", "banana", "cherry", "kiwi", "mango"]

newlist = [x for x in fruits if "a" in x]

print(newlist)
1👍1
How to be a Prompt Engineer 101

The shortest and most comprehensive guide

1. start with an explanation

Make a description and character situation at the beginning of the Prompt

Error example:

Please help me read the following code:

{your input here}

Correct example:

Now let's play the role, you are a senior information security engineer, I will give you a piece of code, please help me read the code and point out where there may be security vulnerable.



Text: """

{your input here}

"""


2. Prompt to describe the situation

In the prompt, it is necessary to describe the context, result, length, format and style as much as possible

Error example:

Write a short story for kids

Correct example:

Write a funny soccer story for kids that teaches the kid that persistence is the key for success in the style of Rowling.

3. gives output in the format

If you are doing data analysis, please give the input template of the format

Error example:

Extract house pricing data from the following text.

Text: """

{your text containing pricing data}

"""

Correct example:

Extract house pricing data from the following text.

Desired format: """

House 1 | $1,000,000 | 100 sqm

House 2 | $500,000 | 90 sqm

... (and so on)

"""

Text: """

{your text containing pricing data}

"""


4. Add some example questions and answers

Sometimes adding some question and answer examples can make GPT more intelligent

Correct example:

Extract brand names from the texts below.

Text 1: Finxter and YouTube are tech companies. Google is too.

Brand names 2: Finxter, YouTube, Google

###

Text 2: If you like tech, you'll love Finxter!

Brand names 2: Finxter

###

Text 3: {your text here}


Brand names 3:

The question and answer example is also a standard template example in fine-tune


5. Simplify the sentence and clarify the purpose


Keep your words as short as possible and don't say useless content


Error example:

ChatGPT, write a sales page for my company selling sand in the desert, please write only a few sentences, nothing long and complex

Correct example:

Write a 5-sentence sales page, sell sand in the desert.

6. Good at using introductory words

Error example:

Write a Python function that plots my net worth over 10 years for different inputs on the initial investment and a given ROI

Correct example:

# Python function that plots net worth over 10

# years for different inputs on the initial

# investment and a given ROI


import matplotlib


def plot_net_worth(initial, roi):
👍73