Last active
May 30, 2020 23:45
-
-
Save Lawrence-Krukrubo/a02740111d89297bb3b60cbadc521e7b to your computer and use it in GitHub Desktop.
Adding code snippets to my article (Loading Different Data Sets) on Medium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First, let's import numpy. | |
import numpy as np | |
# Next, let's save the titanic_df we loaded before, as titanic.csv file. | |
titanic_df.to_csv('titanic.csv', index=False) | |
# Next, let's load titanic.csv as a numpy array, | |
titanic_arr = np.loadtxt('titanic.csv', delimiter = ',', skiprows=1, usecols=[0,1,4]) | |
# I passed the following parameters:- | |
# 1. delimiter = ',' (which is an optional param) | |
# 2. skiprows=1, to skip the first row with the col headers | |
# 3. I pass usecols=[0,1,4], to only select 3 numerical cols. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment