How to Create an Empty List in Python?

To create an empty list in Python, you can use two ways. First, the empty square bracket notation [] creates a new list object without any element in it. Second, the list() initializer method without an argument creates an empty list object too. Both approaches are shown in the following code: Next, you’ll learn many … Read more

The Book of Dash [Reviews]

On this page, I collect reviews from readers of The Book of Dash (NoStarch, 2022): Thanks for all your ❀️! “Perfect for any student of Data Science” “Just the book I’ve been looking for. This is the perfect next step for any Python student seeking to pivot into the Data Science niche. Easy to follow, … Read more

CSV to XML – How to Convert in Python?

Problem Formulation Input: You have some data in a CSV file stored in ‘my_file.csv’ where the first row is the header and the remaining rows are values associated to the column names in the header. Name,Job,Age,Income Alice,Programmer,23,110000 Bob,Executive,34,90000 Carl,Sales,45,50000 Desired Output: You want to store the data in an XML file ‘my_file.xml’ so that each … Read more

How to Skip a Line in Python using \n?

Summary: Python’s newline character \n indicates the end of a line of text. The built-in print() function automatically adds a newline character \n at the end. You can customize this behavior of separating two lines using a single newline character ‘\n’ by changing the default end=’\n’ argument of the print() function to your desired string. … Read more

Ten Best Python 3 Online Compilers [Visual List]

Do you want to run your Python 3 script online? These are the 10 best Python compilers online: #1 – Repl.it Online Python 3 Compiler 🌍 Link: https://repl.it/languages/python3 #2 – Programiz Online Python 3 Compiler 🌍 Link: https://www.programiz.com/python-programming/online-compiler/ #3 – OnlineGDB Python 3 Compiler 🌍 Link: https://www.onlinegdb.com/online_python_compiler #4 – Online-Python.com Compiler 🌍 Link: https://www.online-python.com/ #5 … Read more

Python foreach Loop

πŸ’‘ Question: Does Python have a for each or foreach loop? If so, how does it work? If not, what is the alternative? This article will shed light on these questions. I’ll give you the summary first and dive into the details later: Python has three alternatives to the “for each” loop: A simple for … Read more

17 Ways to Read a CSV File to a Pandas DataFrame

πŸ’¬ Question: How to import a CSV file to a Pandas DataFrame in Python? This article will discuss the most interesting examples to read a CSV file to a Pandas DataFrame. If not specified otherwise, we use the following CSV file for all examples: my_file.csv: Name,Job,Age,Income Alice,Programmer,23,110000 Bob,Executive,34,90000 Carl,Sales,45,50000 Let’s get started! Example 1 – … Read more