Skip to main content

Importing the Dataset in Python

    That is how to import data from csv file in Python.
import pandas as pd
dataset = pd.read_csv('Data.csv')
    It will create a data frame and it will contain exactly the same rows and columns and values from file Data.csv. We will use library pandas which we gave it the shortcut named pd.
x = dataset.iloc[:, :-1].values
y = dataset.iloc[:, -1].values
    We call x for the matrix of features and y for the dependent variable vector. First we will get data from dataset so I am adding a dot after dataset to use pandas's data frame "iloc". We can specify the rows that we want to get and put into x. And the trick to take all the rows whatever dataset you have with whatever number of rows is to add a ":". Because a colon in python means a range and when we specify a range without the lower bound and neither the upper bound that means in Python that we are taking everything in the range.
    We have to specify which columns want to select with the indexes and to separate he rows that we just took from the columns we need here to add a comma. Add a new range here which this time will be colon minus one. Because colon here means the range. We are taking a range here on the left we have nothing that means that we are taking the first index in the index 0 because index in Python started from 0 and then we are going up to minus one. Because the last column in Python means the index of the last column. It will take all the columns excluding the last one.
    In order to finish this line of code, we add dot values and this means that we are taking indeed all the values in all the rows of this dataset and all columns except the last column.
    In y, we only want to get the last column. We definitely don't want to get a range. Minus one is exactly the index of the last column.
The last you can check the data which you import from Data.csv to x and y by
print(x)
print(y)

Comments

Popular Posts

Hướng dẫn chơi Liên Minh Huyền Thoại tất cả server SEA, TAIWAN, NA (Bắc Mĩ)

Cách 1 : Tải trực tiếp server NA (Bắc Mỹ) Cách 2 : Nếu không được các bạn có thể tham khảo cách dưới đây : 1- Tìm file lol.properties trong thư mục: \GameData\Apps\lolVN\Air 2- Mở file lol.properties bằng notepad trong thư mục kia ra, xóa tất cả đi copy toàn bộ dòng dưới vào rồi lưu lại là xong ! Server VN: Code: host=prodvn.lol.garenanow.com xmpp_server_url=chatvn.lol.garenanow.com xmpp_accept_self_signed_cert=true startChat=true storeEnabled=true enableTutorialGame=true lobbyLandingURL=http://lol.garena.com/landing.php ladderURL=http://lienminh.garena.vn/ helpURL=http://lienminh.garena.vn/support lq_uri=https://lqvn.lol.garenanow.com storyPageURL=http://lienminh.garena.vn/ Server SEA: Code: host=prod.lol.garenanow.com xmpp_server_url=chat.lol.garenanow.com xmpp_accept_self_signed_cert=true startChat=true storeEnabled=true enableTutorialGame=true lobbyLandingURL=http://lol.garena.com/landing.php ladderURL=http://lol.garena.com/ladders helpURL=http://lol.garena...

Phần mềm tắt UPnP - Sửa lỗi Unable to join game Đế Chế

Sửa lỗi unable to join game đế chế, không thể thấy room đế chế. Một số máy tính không thể join game hoặc thấy mạng của bạn mình thì hãy làm theo cách của mình. Tải phần mềm UnPnp.exe Bật lên bạn sẽ thấy chữ ở vị trí 2 màu đỏ. Click vào 1 thì vị trí số 2 sẽ sang màu xanh như hình. Lưu ý : Nếu vị trí số 1 không phải là Enable UPnP hoặc Disable UPnP thì mọi người hãy mở file UnPnP.exe bằng cách click phải vào file, chọn Run as Administrator ----> OK. Chúc các bạn thành công và chơi game vui vẻ !

Hướng dẫn chơi Liên Minh Huyền Thoại server Nhật Bản Closed Beta - Tặng tài khoản chơi thử

Trước hết, các bạn cần bản Liên Minh Huyền Thoại bản gốc của Riot (Server Bắc Mỹ (NA), châu Âu, Turkey, ...) Link tải Liên Minh Huyền Thoại bản gốc của Riot: https://signup.leagueoflegends.com/en/signup/redownload Sau đó, vào góc màn hình bấm chọn dấu mũi tên đi xuống cạnh North America (cái này thì tùy vì mình chơi server NA) Chọn  North America Một bảng hiện ra chọn Japan Chọn Save Đợi Liên Minh Huyền Thoại update bản tiếng Nhật về. Closed Beta bắt đầu từ ngày 4 tháng 2 năm 2016 mà hôm mình viết bài này mới chỉ 3/2/2016 nên phải đợi qua ngày mới cho test nhé. Dưới đây là 1 số account mình được tặng để test nhé : Video hướng dẫn :