python DataCamp:用Python导入数据(第1部分)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python DataCamp:用Python导入数据(第1部分)相关的知识,希望对你有一定的参考价值。

# Import packages
from sqlalchemy import create_engine
import pandas as pd

# Create engine: engine
engine = create_engine('sqlite:///Chinook.sqlite')

# Execute query and store records in DataFrame: df
df = pd.read_sql_query('SELECT * FROM Album', engine)

# Print head of DataFrame
print(df.head())
from sqlalchemy import create_engine
import pandas as pd

engine = create_engine('sqlite:///Chinook.sqlite')

# Open engine in context manager
# Perform query and save results to DataFrame: df
with engine.connect() as con:
    rs = con.execute('SELECT LastName, Title FROM Employee')
    df = pd.DataFrame(rs.fetchmany(size=3))
    df.columns = rs.keys()

# Print the length of the DataFrame df
print(len(df))

# Print the head of the DataFrame df
print(df.head())
import numpy

# Print the keys of the MATLAB dictionary
print(mat.keys())

# Print the type of the value corresponding to the key 'CYratioCyt'
print(type(mat['CYratioCyt']))

# Print the shape of the value corresponding to the key 'CYratioCyt'
print(numpy.shape(mat['CYratioCyt']))

# Subset the array and plot it
data = mat['CYratioCyt'][25, 5:]
fig = plt.figure()
plt.plot(data)
plt.xlabel('time (min.)')
plt.ylabel('normalized fluorescence (measure of expression)')
plt.show()

以上是关于python DataCamp:用Python导入数据(第1部分)的主要内容,如果未能解决你的问题,请参考以下文章

python DataCamp:Python数据科学简介https://www.datacamp.com/courses/intro-to-python-for-data-science

python DataCamp:用于数据科学的中级Python https://www.datacamp.com/courses/intermediate-python-for-data-scienc

python DataCamp:Python数据科学工具箱(第2部分)https://www.datacamp.com/courses/python-data-science-toolbox-part

学习笔记之Intermediate Python for Data Science | DataCamp

Python .loc 混淆

14张Python速查表玩转数据分析&可视化&机器学习