Selected topic
Data Analysis
Prefer practical output? Use related tools below while reading.
read_csv function to load data from a CSV file.head(), tail(), and info() to quickly inspect your data.python
import pandas as pd# Create a dictionary with data
data = {'Name': ['John', 'Anna', 'Peter'],
'Age': [28, 24, 35],
'City': ['New York', 'Paris', 'London']}
# Create a DataFrame from the dictionary
df = pd.DataFrame(data)
print(df)
Name Age City
0 John 28 New York
1 Anna 24 Paris
2 Peter 35 Londonpython
import pandas as pd# Create a DataFrame with missing data
df = pd.DataFrame({'Name': ['John', 'Anna', None, 'Peter'],
'Age': [28, 24, np.nan, 35]})
print(df)
# Identify the missing values using isnull()
missing_values = df.isnull()
print(missing_values)
Name Age
0 John 28.0
1 Anna 24.0
2 NaN NaN
3 Peter 35.0[False False True False]
This is just a brief introduction to Pandas, but it should give you an idea of how to get started with using the library for data analysis in Python.
Note: I assumed numpy is already installed and imported as np.