DataFrame Object in Pandas is used to plot the data table as well as to keep the data for the later usage. Let us look at a few examples below.
Hello and welcome back, in this article we will take a look at the DataFrame object and its usages. We will continue to look at the usage of other Objects before we will actually start to create this new web analytics project.
Before anything, let us create the DataFrame object.
import pandas as pd import numpy as np dates = pd.date_range('1/1/2019', periods=9) # create the dates index with nine rows df = pd.DataFrame(np.random.randn(9, 4), index=dates, columns=['A', 'B', 'C', 'D']) # randomly generate a nine rows 4 columns array list and provide the name for each column
Next we will access the element in column 3 and row 4.
import pandas as pd import numpy as np dates = pd.date_range('1/1/2019', periods=9) df = pd.DataFrame(np.random.randn(9, 4), index=dates, columns=['A', 'B', 'C', 'D']) s = df['C'] print(df) print(s[[dates[3]]]) # print out the data under this row, column
Finally, we will find the mean values for each column.
import pandas as pd import numpy as np dates = pd.date_range('1/1/2019', periods=9) df = pd.DataFrame(np.random.randn(9, 4), index=dates, columns=['A', 'B', 'C', 'D']) print(df) print(df.mean()) # plot the mean average value for each column
There are more methods in the DataFrame object but the above will be great enough to help us get started!
from Planet Python
via read more
No comments:
Post a Comment