Login
📚 Introduction to Python Programming
Chapters ▾
⇩ Download ▾

15.6 Summary

Highlights from this chapter include:

At this point, you should be able to write programs to create data structures to store different datasets and explore and visualize datasets.

Table 15.13 Chapter 15 reference.
FunctionDescription
np.arrayCreates an ndarray from a list or tuple.
np.zerosCreates an array of zeros.
np.onesCreates an array of ones.
np.random.rand(n, m)Creates an array of random numbers with n rows and m columns
np.genfromtxt('data.csv', delimiter=',')Creates an array from a CSV file.
pd.DataFrameCreates a DataFrame from a list, dictionary, or an array.
pd.read_csvCreates a DataFrame from a CSV file.
df.headReturns the first few rows of a DataFrame.
df.tailReturns the last few rows of a DataFrame.
df.infoProvides a summary of the DataFrame, including the column names, data types, and the number of non-Null values.
df.describeGenerates the column count, mean, standard deviation, minimum, maximum, and quartiles.
df.value_countsCounts the occurrences of unique values in a column and presents them in descending order.
df.uniqueReturns an array of unique values in a column.
locAllows for accessing data in a DataFrame using row/column labels.
ilocAllows for accessing data in a DataFrame using row/column integer-based indexes.
df[condition]Selects only the rows that meet the given condition.
df.loc[start_row:end_row, start_column:end_column]Slices using label ranges.
df.loc[[label1, label2,...],:]Slices rows that are in the list [label1, label2,...].
df.isnullReturns a Boolean array with Boolean values representing whether each entry has been Null.
fillnaReplaces Null values.
dropnaRemoves all rows containing a Null value.
plt.bar(x, height)Takes in two inputs, x and height, and plots bars for each x value with the height given in the height variable.
plt.plot(x, y)Takes in two inputs, x and y, and plots lines connecting pairs of (x, y) values.
plt.scatter(x, y)Takes in two inputs, x and y, and plots points representing (x, y) pairs.
plt.hist(x)Takes in one input, x, and plots a histogram of values in x to show distribution or trend.
plt.boxplot(x)Takes in one input, x, and represents minimum, maximum, first, second, and third quartiles, as well as outliers in x.