How to Export a DataFrame to Excel in R

The writexl package can be used to export a DataFrame to Excel in R: Copy library(“writexl”) write_xlsx(The DataFrame name, “Path to store the Excel file\\file name.xlsx”) Steps to Export a DataFrame to Excel in R Step 1: Install the writexl package Type the following command in the R console to install the writexl package: Copy … Read more

Categories R

How to apply an input() function in Python

To apply an input function in Python: Copy value = input() Next, you’ll see 3 examples of an input function: 3 Examples of an Input Function in Python Example 1: input function for a text/string You can utilize an input function in order to gather text from users. For example, the following syntax can be … Read more

Convert Text File to CSV using Python

To convert a text file to a CSV file using Python: Copy import pandas as pd read_file = pd.read_csv(r”Path where the Text file is stored\File name.txt”) read_file.to_csv(r”Path where the CSV will be saved\File name.csv”, index=False) Steps to Convert a Text File to CSV using Python Step 1: Install the Pandas package If you haven’t already … Read more

Convert CSV to JSON using Python

To convert a CSV file to a JSON file using Python: Copy import pandas as pddf = pd.read_csv(r”Path where the CSV file is saved\File Name.csv”)df.to_json(r”Path where the new JSON file will be stored\New File Name.json”) Steps to Convert CSV to JSON using Python Step 1: Prepare the CSV File To start, prepare a CSV file … Read more

How to Move a File or Directory in Python

To move a file in Python: Copy import shutil original = r”original path of the file\file_name.file_extension” target = r”target path to store the file\file_name.file_extension” shutil.move(original, target) Steps to Move a File in Python Step 1: Capture the Original Path To begin, capture the original path where your file is currently stored. For example, let’s suppose … Read more

Convert PNG to JPG using Python

To convert PNG to JPG using Python: Copy from PIL import Imageim = Image.open(r”path where the PNG is stored\file name.png”)im.save(r”path where the JPG will be stored\new file name.jpg”) Steps to Convert PNG to JPG using Python Step 1: Install the PIL package You can install the PIL package using the command below: Copy pip install … Read more

How to Sort a List in Python

To sort a List in Python in an ascending order: Copy my_list.sort() To sort a List in a descending order: Copy my_list.sort(reverse=True) 4 Cases of Sorting a List Case 1: Sort a List in an Ascending Order To start, create a List of names: Copy names = [“Jon”, “Maria”, “Bill”, “Liam”, “Emma”]print(names) The resulted List: … Read more

How to Export DataFrame to CSV in Julia

To export a DataFrame to CSV in Julia: Copy using CSVCSV.write(“Path where your CSV file will be stored\\File Name.csv”, df) Steps to Export DataFrame to CSV in Julia Step 1: Install the Relevant Packages If you haven’t already done so, install the DataFrames and CSV packages in Julia. You can install the DataFrames package using: … Read more

How to Add R to Jupyter Notebook (full steps)

You can add R to Jupyter Notebook by typing the following command in the Anaconda Prompt: Copy conda install -c r r-irkernel Here are the full steps to add R to Jupyter Notebook. Steps to Add R to Jupyter Notebook Step 1: Open the Anaconda Prompt To start, open the Anaconda Prompt. You’ll then see … Read more

Categories R

How to Copy a File using Python

In this short guide, you’ll see how to copy a file, from one folder to another, using Python. To start, here is a simple template that you may use to copy a file in Python using shutil.copyfile: Copy import shutil source = r”source path where the file is currently stored\file_name.file_extension” target = r”target path where … Read more