<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Now fundamentally the data frame is just an abstraction but it provides a ton of useful tools that you’re going to get to see. This video is just going to go over the basic idea of the data frame as well as how to create them.
Step1:  You can create DataFrames by passing in np arrays, lists of series, or dictionaries.
Step2:  We’ll be covering a lot of different aspects here but as always we’re going to start with the simple stuff. A simplification of a data frame is like an excel table or sql table. You’ve got columns and rows.
In more specific pandas terms, it's a more powerful list of series. Each column is a Series of data and it just so happens these can have relationships.
You can see that if we just pass in a list of lists it treats them like columns. Of course if that’s an issue we can just transpose it and get we’ll get them as columns.
Step3:  This should be familiar because it’s the same way that we transpose ndarrays in numpy.
Of course we can also specify them as explicit columns but passing in a dictionary where the keys are the column names and the values are the lists of each item (or the rows).
Step4:  Now you’ll see that if these lengths are not the same, we’ll get a ValueError so it’s worth checking to make sure your data is clean before importing or using it to create a DataFrame
Step5:  We can rename the columns easily and even add a new one through a relatively simple dictionary like assignment. I'll go over some more complex methods later on.
Step6:  Now just like Series, DataFrames have data types, we can get those by accessing the dtypes of the DataFrame which will give us details on the data types we've got.
Step7:  Of course we can sort maybe by a specific column or by the index(the default).
Step8:  We've seen how to query for one column and multiple columns isn't too much more difficult.
We can get upper and lower case columns
Step9:  We can also just query the index as well. We went over a lot of that in the Series Section and a lot of the same applies here.
We can query by index location or by letters
<ASSISTANT_TASK:>
Python Code:
import string
upcase = [x for x in string.ascii_uppercase]
lcase = [x for x in string.ascii_lowercase]
print(upcase[:5], lcase[:5])
Explanation: Now fundamentally the data frame is just an abstraction but it provides a ton of useful tools that you’re going to get to see. This video is just going to go over the basic idea of the data frame as well as how to create them.
End of explanation
pd.DataFrame([upcase, lcase])
Explanation: You can create DataFrames by passing in np arrays, lists of series, or dictionaries.
End of explanation
pd.DataFrame([upcase, lcase]).T
Explanation: We’ll be covering a lot of different aspects here but as always we’re going to start with the simple stuff. A simplification of a data frame is like an excel table or sql table. You’ve got columns and rows.
In more specific pandas terms, it's a more powerful list of series. Each column is a Series of data and it just so happens these can have relationships.
You can see that if we just pass in a list of lists it treats them like columns. Of course if that’s an issue we can just transpose it and get we’ll get them as columns.
End of explanation
letters = pd.DataFrame({'lowercase':lcase, 'uppercase':upcase})
letters.head()
Explanation: This should be familiar because it’s the same way that we transpose ndarrays in numpy.
Of course we can also specify them as explicit columns but passing in a dictionary where the keys are the column names and the values are the lists of each item (or the rows).
End of explanation
pd.DataFrame({'lowercase':lcase + [0], 'uppercase':upcase})
letters.head()
Explanation: Now you’ll see that if these lengths are not the same, we’ll get a ValueError so it’s worth checking to make sure your data is clean before importing or using it to create a DataFrame
End of explanation
letters.columns = ['LowerCase','UpperCase']
np.random.seed(25)
letters['Number'] = np.random.random_integers(1,50,26)
letters
Explanation: We can rename the columns easily and even add a new one through a relatively simple dictionary like assignment. I'll go over some more complex methods later on.
End of explanation
letters.dtypes
letters.index = lcase
letters
Explanation: Now just like Series, DataFrames have data types, we can get those by accessing the dtypes of the DataFrame which will give us details on the data types we've got.
End of explanation
letters.sort('Number')
letters.sort()
Explanation: Of course we can sort maybe by a specific column or by the index(the default).
End of explanation
letters[['LowerCase','UpperCase']].head()
Explanation: We've seen how to query for one column and multiple columns isn't too much more difficult.
We can get upper and lower case columns
End of explanation
letters.iloc[5:10]
letters["f":"k"]
Explanation: We can also just query the index as well. We went over a lot of that in the Series Section and a lot of the same applies here.
We can query by index location or by letters
End of explanation
<END_TASK>