Pandas Flashcards
Write the code that is required to run pandas
import pandas as pd
Read in a csv file into pandas given
import pandas as pd
pd.read_csv(‘myfile.csv’)
Read in a excel file into pandas given
import pandas as pd
pd.read_excel(‘my_file.xlsx’)
Read in a json file into pandas given
import pandas as pd
pd.read_json(‘my_file.json’)
What is pd in import pandas as pd?
an alias
Read in a DataFram file into pandas given
import pandas as pd
pd.DataFrame.from_dict(‘my_file.???)
What is the syntax to export DataFrame to other formats?
df.to_csv(‘my_file.csv’)
df.to_excel(‘my_file.xslx’)
df.to_json(‘my_file.json’)
df.to_dict(‘my_file.???’)
True or False
like MS Excel, Pandas handles spreedsheet like data called a DataFrame
True
.txt stands for?
tab separated file, known as a text file.
.csv stands for?
comma separated file, known as a spreadsheet
.xlsx stands for?
Microsoft Excel Open XML Spreadsheet
.json stands for?
JavaScript Object Notation
What is a delimiter in Pandas?
Commas is excel type files are delimiters they separate the data, in Pandas you can detrimine what is going to be used to separate the data being loaded in such as ‘\t’ in .txt files
Write the code to read in headers
df.columns( )
print(df.columns)
Code to read in a specific column
df. ([‘Name’])
df. Name