Pandas#
Create a Pandas series called
xwith all positive integers from 0 to 99.
Create another Pandas series derived from
xwhich contains the values of \(x^2\). Call this Seriesx_squared.
Create a Pandas data frame containing
xandx_squaredas columns.
Add a column with the cosine of
x_squaredin degrees and call itcos_x_squared. (Hint 1: Use themathmodule for getting a value forpiand for thecosfunction. Hint 2: It is not possible to callmath.cosdirectly on a Pandas series, but we can use.apply(math.cos)on a series.)
Select every second line from the dataframe starting on line 23 and print the selection.
Choose
xas the index of the dataframe. Then print the portion of the dataframe which represents values ofxbetween 11.3 and 47.5.
Write the data frame to disk (into a CSV file). Then, load the CSV file into a new dataframe.
Visualize the columns
x_squaredandcos_x_squaredagainst the indexx.
Change the index to
x_squaredand visualize the clumncos_x_squaredagainst the new index.