C'est du Python et vous pouvez l'apprendre comme moi ! Python, pas le serpent, le langage.

Difference between python --version and python -v

Difference between python --version and python -v

Difference between python --version and python -v. These two commands have completely different purposes: python --version Shows the Python interpreter's version number Example output: Python 3.9.7 This is the standard way to check which version of Python you're running It's equivalent to python -V (capital V) python -v Activates verbose...

When to use !pip, %pip or !uv in Python?

When to use !pip, %pip or !uv in Python?

For Jupyter Notebooks, the modern approach is: %pip install such as %pip install ShopifyAPI. %pip is a magic command The `%pip is called a "magic command" and it is preferred over `!pip` because it ensures the package is installed in the same Python environment that the kernel is using. But...

How to change tag style in bulk? For an experiment

How to change tag style in bulk? For an experiment

Not so long ago, I faced an issue while wanted to test a colleague idea: how can we test on which links user are more willing to click. TL;DR If my article is too long, these are the steps: Define the scope Extract or get the HTML content Split your group...

How to save a .parquet file in Python?

How to save a .parquet file in Python?

To save a .parquet file with Python, you can use the pandas library, which provides a convenient way to read and write data in a variety of formats, including Parquet. Let me share with you an example: ```Python import pandas as pd create a sample DataFrame data = {'name': ['Alice',...

Type hints in Python function

Type hints in Python function

While reviewing code from a colleague, I came across a -> pd.DataFrame in a Python function. I discovered that this indicates that the function is expected to return a pandas DataFrame.

What is a .parquet file?

What is a .parquet file?

div> I was recently introduced to .parquet extension files. Let me share with you what I learned! Parquet files are popular for storing and processing large datasets in big data environments. Introduction: a few words about the .parquet Parquet file is a columnar storage file format that is commonly used...

Unique URLs on a dataframe column in Python

Unique URLs on a dataframe column in Python

Might be a simple trick, but wanted to share something I am using on a regular basis: unique URL per column on a dataframe and how to export it! I will use pandas so start by importing the libraryimport pandas as pd I am labelling this as Python SEO as...

How to read a `.parquet` file in Python?

How to read a `.parquet` file in Python?

To read a .parquet file with Python, the pandas library is your friend. In fact, pandas provides a convenient way to read and write data in a variety of formats (you might be familiar with CSV or XLS[X] files), including Parquet.

How to import Python libraries

How to import Python libraries

This import will work if you are using any version of Python (meaning Python 2 or Python 3). How to import a library To import a library, you will have to use import + {the name of your library}. So you could do this to import libraries one by one:...

How to upload files in Google Colab

Importer des fichiers dans Google Colab

Si vous aimez les Notebook (comme Google Colab ou Jupyter Notebook), vous allez aimer cette astuce pour importer un ou plusieurs fichiers grâce à une fonction. Une fonction, qui crée un bon moyen d'importer les fichiers Vous trouverez ci-dessous la fameuse fonction et ensuite, vous n'aurez plus qu'a cliquer sur...

Find and remove empty column in Python with pandas

Trouver et supprimer une colonne vide via Panda

Rechercher et supprimer des colonnes vides dans le dataframe grâce/via Pandas en Python. # Find the columns where each value is null cols_vides = [col for col in df.columns if df[col].isnull().all()] # Drop these columns from the dataframe df.drop(cols_vides, axis=1, inplace=True) Trouver les columns avec des valeurs 'null' cols_vides =...

Rich Google Colab tables

Tableaux enrichis dans Google Colab

Une astuce bien pratique aujourd'hui et cela même si vous utilisez déjà pandas ou numpy : créer des tableaux enrichis sur le Notbook de Google. Ces astuces et Notebook sont principalement utilisables pour Python -- Même si vous pouvez lancer des Notebook pour des scripts R. Comment faire pour avoir...

Know and display all column from a dataframe in Python

Connaître (et afficher) toutes les colonnes d'un dataframe en Python

Connaître (et afficher) toutes les colonnes d'un dataframe en Python Pré-requis Nous allons une nouvelle fois utiliser la librairie (non moins fameuse) pandas utilisée en Python. Pour l'installation vous avez les solutions ci-dessous: pour Python pip install pandas pour Python 3 pip3 install pandas Vous n'aurez qu'à installer une seule...

Diff date usage in Python

Diff date usage in Python

import difflib import pandas as pd from datetime import date date = date.today() today = date.strftime("%Y-%m-%d") document = today + "-diff" document_txt = "data/" + document + ".txt" document_csv = "data/" + document + ".csv" with open('robots-live.txt') as robots_live, open('robots-staging2.txt') as robots_staging: diff = difflib.unified_diff( robots_live.readlines(), robots_staging.readlines(), fromfile='robots-live.txt', tofile='robots-staging.txt', )...

Python 101: How it all started with Python for me

Python 101 : mes débuts en Python

  <p>Alors ce n'est pas moi qui est créé la structure du cours ou de ce point, c'est sur Open Classroom <a href="https://openclassrooms.com/en/courses/4262331-demarrez-votre-projet-avec-python/">https://openclassrooms.com/en/courses/4262331-demarrez-votre-projet-avec-python/</a>, tous droits réservés donc à Open Classroom. Et pourquoi 101, parce que je reprends les bases (en vrai et dans cet article) grâce à ce cours, j'apprends...

Quelques conseils rapides pour être meilleur avec Python. Je suis loin de tout savoir, n'hésitez pas à me contacter sur BlueSky, c'est juste un moyen pour moi de partager ce que j'apprends et quelques bribes de mes connaissances.

Ce que je sais à propos de Python

Je ne connais pas grand-chose à Python, mais j'apprends quelques trucs au fur et à mesure.

De plus, mon entreprise utilise ce langage informatique pour les tests et les études, c'est donc une bonne école pour moi aussi ! Cette catégorie portera sur le langage informatique, pas sur le serpent.

Python ou R

Cela dit, comme pour le langage R, je ne prétendrai pas révolutionner les choses, mais je vous donnerai quelques conseils qui m'ont aidé à améliorer ma capacité à automatiser les tâches dans mes rôles d'analyste de données et de spécialiste SEO.

Mon objectif avec cette catégorie Python

Mon objectif est de vous emmener avec moi et de partager les conseils que j'ai trouvés sur Python, ainsi que quelques petites astuces pour les débutants comme je le suis - ou l'ai été.