Import Data

Secara garis besar, tidak banyak perbedaan cara melakukan import data di R dan Python. Berikut ini merupakan perbandingan penulisan code kedua software tersebut.

Working Directory

#R
getwd() 
 
#Python
pwd()

Input data file .csv

#R
read.csv("D:\\holt_winter.csv",sep=';',header=TRUE)
 
#Python
import pandas as pd
pd.read_csv("D:\\holt_winter.csv",sep=';',header=True)

Input data file .xlsx

#R
library(xlsx)
read.xlsx("D:\\holt_winter.xlsx",header=TRUE,sheetName='Sheet1')
 
#Python
import pandas as pd
pd.read_excel("D:\\holt_winter.xlsx",header=True,sheet_name='Sheet1')

Input data file .json

#R
library(rjson)
fromJSON("D:\\holt_winter.json")
 
#Python
import pandas as pd
pd.read_json("D:\\holt_winter.json")