Reading data from CSV file and creating Pandas DataFrame using read_csv() in Python with options

Опубликовано: 13 Май 2021
на канале: plus2net
1,250
7

We can read one csv file from our system and using that we can create Pandas DataFrame. We will use read_csv() method for reading data from local system.
https://www.plus2net.com/python/panda...
import pandas as pd
df=pd.read_csv('D:\\my_data\\my_file.xlsx')
The path we used here is D drive and my_data as directory , you can change it based on location of csv file.
index_col
Dataframe will add one index column, we can specify to use one of our column as index column by saying index_col
df=pd.read_csv('D:\\my_data\\my_file.xlsx',index_col='id')
header
By default the column header is 0. We can give integer values. Here is the code to start from 1st row
df=pd.read_csv('D:\\my_data\\my_file.xlsx',header=1)
We can specify not to use any header and use all as data
df=pd.read_csv('D:\\my_data\\my_file.xlsx',header=None)
names
We can specify our one list of names to be used as headers.
cl=['c1','c2','c3','c4']
df=pd.read_csv('D:\\my_data\\my_file.xlsx',names=cl)

  / plus2net  
#pandas_read_csv #dataframereadcsv #pandascsv #plus2net #pandas #datascience #pandastutorials


На этой странице сайта вы можете посмотреть видео онлайн Reading data from CSV file and creating Pandas DataFrame using read_csv() in Python with options длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь plus2net 13 Май 2021, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 1,250 раз и оно понравилось 7 зрителям. Приятного просмотра!