Week 13
Week 13
2024
CEng 240 – Spring 2021
Week 14 13
Sinan Kalkan
This Week
METU Computer Engineering
¢ Overview
¢ Installation
¢ DataFrames
¢ Accessing data in DataFrames
¢ Modifying data in DataFrames
¢ Analyzing data in DataFrames
¢ Presenting data in DataFrames
¢ A wide collection of
file formats
¢ Each format has a
reader and a writer
More on pd.read_csv():
• Automatically loads column headers
• If your file does not have a header, use: pd.read_csv(filename, header=None)
• If you want to read specific columns, use:
pd.read_csv(filename, usecols=[‘column name 1’, ...])
• For more information & control, see help(pd.read_csv)
Note that the column names were retrieved from the keys of the dictionary
¢ df.iloc[<row index>
§ for integer indexes
¢ df.loc[<row name>]
§ for named indexes
¢ Row & column indexing can be
combined:
§ df.loc[‘Amanda’, ‘Grade’]
§ df.iloc[1, 1]
¢ With integer indexes, Python’s
slicing ([start:end:step]) can be
used
2020 S. Kalkan - CEng 240 15
Modifying Data
METU Computer Engineering
¢ plot() function
¢ Overview
¢ Installation
¢ Anatomy of a figure/plot
¢ Preparing your data
¢ Drawing single plots
¢ Drawing multiple plots
¢ Changing elements of a plot
¢ Canvas / drawing
area
§ scatter plot, line
plot, ...
¢ Axes
§ ticks, tick labels,
axis labels
¢ figure title
¢ legend
¢ Use
matplotlib.pylot
directly