Python trung cấp của @DataCamp - mặc dù nền tảng của tôi thiên về Phát triển web, nhưng các khóa học này (Giới thiệu & Trung cấp), tập trung nhiều hơn vào khía cạnh Khoa học dữ liệu của #python cung cấp phần giới thiệu tuyệt vời và thực hành về một số thư viện tuyệt vời của Python, chẳng hạn . Rất khuyến khích, dễ dàng truy cập dữ liệu, thao tác và trực quan hóa thông qua các công cụ này. #data #pandas #numpy #datacamp
Pandas là một công cụ thao tác dữ liệu cấp cao được xây dựng trên Numpy. Nó có thể đưa tập dữ liệu xuống cấu trúc dạng bảng và lưu trữ nó trong DataFrame. Mảng Numpy không hữu ích trong trường hợp này vì dữ liệu trong bảng có thể thuộc các loại khác nhau
DataFrame từ điển
import matplotlib.pyplot as plt year = [1950, 1970, 1990, 2010] pop = [2.519, 3.692, 5.263, 6.972] plt.plot(year, pop) #(x, y) plt.show()# before this step, you can add labels or other things to customize your plot.
4
import matplotlib.pyplot as plt year = [1950, 1970, 1990, 2010] pop = [2.519, 3.692, 5.263, 6.972] plt.plot(year, pop) #(x, y) plt.show()# before this step, you can add labels or other things to customize your plot.
5
DataFrame từ tệp csv
import matplotlib.pyplot as plt year = [1950, 1970, 1990, 2010] pop = [2.519, 3.692, 5.263, 6.972] plt.plot(year, pop) #(x, y) plt.show()# before this step, you can add labels or other things to customize your plot.
6
import matplotlib.pyplot as plt year = [1950, 1970, 1990, 2010] pop = [2.519, 3.692, 5.263, 6.972] plt.plot(year, pop) #(x, y) plt.show()# before this step, you can add labels or other things to customize your plot.
7
Lập chỉ mục và chọn dữ liệu
Dấu ngoặc vuông. chức năng hạn chế
import matplotlib.pyplot as plt year = [1950, 1970, 1990, 2010] pop = [2.519, 3.692, 5.263, 6.972] plt.plot(year, pop) #(x, y) plt.show()# before this step, you can add labels or other things to customize your plot.
0
import matplotlib.pyplot as plt year = [1950, 1970, 1990, 2010] pop = [2.519, 3.692, 5.263, 6.972] plt.plot(year, pop) #(x, y) plt.show()# before this step, you can add labels or other things to customize your plot.
9
Phương pháp nâng cao. loc (dựa trên nhãn), iloc (dựa trên vị trí số nguyên)
lộc
1 2 3 4 5 6
0
1 2 3 4 5 6
1
iloc
1 2 3 4 5 6 7 8 9 10 11 12 13 14
1 2 3 4 5 6
3
ix cách kết hợp loc và iloc (không có trong khóa học)
Logic, luồng điều khiển và lọc
Toán tử so sánh
Các toán tử so sánh là các toán tử có thể cho biết các giá trị Python liên quan như thế nào và dẫn đến một giá trị boolean
toán tử số
1 2 3 4 5 6
1 2 3 4 5 6
5
so sánh khác
1 2 3 4 5 6
6
1 2 3 4 5 6
7
Toán tử Boolean. và, hoặc, không
1 2 3 4 5 6
0
1 2 3 4 5 6
9
Khi làm việc với Numpy.
import matplotlib.pyplot as plt year = [1950, 1970, 1990, 2010] pop = [2.519, 3.692, 5.263, 6.972] plt.plot(year, pop) #(x, y) plt.show()# before this step, you can add labels or other things to customize your plot.
72,
import matplotlib.pyplot as plt year = [1950, 1970, 1990, 2010] pop = [2.519, 3.692, 5.263, 6.972] plt.plot(year, pop) #(x, y) plt.show()# before this step, you can add labels or other things to customize your plot.
73 và
import matplotlib.pyplot as plt year = [1950, 1970, 1990, 2010] pop = [2.519, 3.692, 5.263, 6.972] plt.plot(year, pop) #(x, y) plt.show()# before this step, you can add labels or other things to customize your plot.
74
import matplotlib.pyplot as plt year = [1950, 1970, 1990, 2010] pop = [2.519, 3.692, 5.263, 6.972] plt.plot(year, pop) #(x, y) plt.show()# before this step, you can add labels or other things to customize your plot.
00
import matplotlib.pyplot as plt year = [1950, 1970, 1990, 2010] pop = [2.519, 3.692, 5.263, 6.972] plt.plot(year, pop) #(x, y) plt.show()# before this step, you can add labels or other things to customize your plot.
01
Câu điều kiện. nếu, nếu không, elif
import matplotlib.pyplot as plt year = [1950, 1970, 1990, 2010] pop = [2.519, 3.692, 5.263, 6.972] plt.plot(year, pop) #(x, y) plt.show()# before this step, you can add labels or other things to customize your plot.
0
import matplotlib.pyplot as plt year = [1950, 1970, 1990, 2010] pop = [2.519, 3.692, 5.263, 6.972] plt.plot(year, pop) #(x, y) plt.show()# before this step, you can add labels or other things to customize your plot.
03
Lọc khung dữ liệu Pandas
import matplotlib.pyplot as plt year = [1950, 1970, 1990, 2010] pop = [2.519, 3.692, 5.263, 6.972] plt.plot(year, pop) #(x, y) plt.show()# before this step, you can add labels or other things to customize your plot.
00
import matplotlib.pyplot as plt year = [1950, 1970, 1990, 2010] pop = [2.519, 3.692, 5.263, 6.972] plt.plot(year, pop) #(x, y) plt.show()# before this step, you can add labels or other things to customize your plot.
05Vòng lặp
Trong khi lặp lại
Vòng lặp While có thể giúp lặp lại câu lệnh if và có thể rất hữu ích trong một số trường hợp. Ví dụ: lặp đi lặp lại cùng một bước cho đến khi đáp ứng một điều kiện cụ thể, để nó có thể dừng tại một số điểm