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

7554 bất ngờ mở miễn phí tặng game thủ nhân dịp kỷ niệm 65 năm chiến thắng Điện Biên Phủ

  "Tiến tới kỷ niệm 65 năm chiến thắng Điện Biên Phủ(7/5/1954 - 7/5/2019) . Và cũng nhân dịp kỷ niệm 10 năm làm game của Hiker Games. Như đã hứa, xin được gửi tặng cộng đồng game thủ Việt Nam phiên bản 7554 hoàn toàn miễn phí. Các bạn có thể truy cập vào website http://www.7554.vn để download. Để đảm bảo không có hiểu nhầm nào, xin lưu ý, đây không phải là phiên bản làm lại của 7554.  Đây chỉ là phiên bản đã loại bỏ phần kiểm tra bản quyền để bất cứ ai cũng có thể tải về và trải nghiệm game. Chúc các bạn chơi game vui vẻ!"  Via 7554 Dưới đây là video hướng dẫn tải game:  Chúc các bạn chơi game vui vẻ !

山梨日帰り温泉マイコース - Tận hưởng suối nước nóng Yamanashi đi về trong ngày

山梨日帰り温泉マイコース 10:00 武田神社にて 紅葉狩り 11:00 AZ山梨サーキットにて 猛スピードで10週走行。Gが凄い!           ラップタイムは自動計測、印字されます。           5週:1,500円、10週:2,000円 12:30 ほったらかし温泉にて 透明度抜群の天然温泉でゆっくり           温泉上がったあとは、キャンプ気分で           伝説のカリーを味わいながら富士山を眺める。激ウマ!           チキンカリー:1,100円、チキン肉カリー:1,600円 15:00 帰宅する前に隣接する直売所にて新鮮な野菜と果物をゲット           シャインマスカット粒パック:300円、一房:800円 Tận hưởng suối nước nóng Yamanashi đi về trong ngày 10:00 Ngắn lá đó ở đền Takeda 武田神社 11:00 Đua xe 10 vòng tốc độ ở AZ山梨サーキット. Phê lòi!           Lap time đo tự động và in ra cho mình.           5 vòng:1,500円、10 vòng:2,000円 12:30 Thong thả ngâm mình suối nước nóng thiên nhiên           ほったらかし温泉. Nước trong vắt và cảnh đẹp tuyệt vời..           Sau khi tắm xong, thưởng thức món cà ri truyền thuyết,     ...

Kinh nghiệm farm đồng trong MIR4

Đồng trong MIR4 là 1 loại tiền tệ ngoài mua đồ trong tạp hóa và trong shop hay cường hóa, chế đồ thì không có nhiều giá trị lắm nhưng không thể thiếu. Vì vậy nay mình xin chia sẻ ít kinh nghiệm farm đồng trong bản đồ hình vuông cho anh em. Farm 1 ngày dùng 2 ngày thoải mái. Chúc anh em chơi game vui vẻ !