Eugenio < Erdos > Andreose

Logo
(πŸ‘‹) Hi there!
(πŸ’») Statistician in love with Computer Science stuff.
(♠️) Been playing around with Language Models way before things turned dramatically fancy into AI.
(πŸ“) Currently based in Barcelona.
Let's get in touch!

Tech Notes

Here you’re going to find some code notes recorded along the way. Blocks are mainly written in Python or Pyspark, but of course, R is always in my ❀️

Please have a look (forgive the mess). 😊

How to except all errors in Python (ugly and dangerous way)

import traceback
import logging

try:
    whatever()
except Exception as e:
    logging.error(traceback.format_exc())
    # Logs the error appropriately. 

How to check if a pd.DataFrame object is empty:

import pandas as pd

# Create an empty DataFrame
df = pd.DataFrame()

# Check if the DataFrame is empty
if df.empty:
    print('DataFrame is empty')
else:
    print('DataFrame is not empty')

back