This file contains 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
col0 | col1 | col2 | |
---|---|---|---|
12 | 24 | 2019 |
This file contains 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
import pandas as pd | |
if __name__ == '__main__': | |
# Parse columns 0 through 2 as a date. | |
df = pd.read_csv('read_csv_keep_date.csv', header=0, | |
parse_dates=[['col0', 'col1', 'col2']], keep_date_col=True) |
This file contains 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
col0 | col1 | col2 | |
---|---|---|---|
12-25-19 | 0 | 1 |
This file contains 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
import pandas as pd | |
# Set column 0 as the index and parse it as a date. | |
df = pd.read_csv('read_csv_parse_date.csv', header=0, index_col='col0', parse_dates=True) |
This file contains 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
col0 | col1 | col2 | |
---|---|---|---|
yes | no | maybe |
This file contains 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
import pandas as pd | |
if __name__ == '__main__': | |
# Set yes & maybe to True and no to False. | |
df = pd.read_csv('read_csv_true_values.csv', header=0, | |
true_values=['yes', 'maybe'], false_values=['no']) |
This file contains 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
col0 | col1 | |
---|---|---|
'a' | 2.0 | |
'b' | 4.0 | |
'c' | 6.0 |
This file contains 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
import pandas as pd | |
def double_number(x): | |
""" Double a passed float | |
:param x: Float that will be doubled. | |
:return: A doubled float. | |
""" | |
return float(x) * 2 |
This file contains 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
employee_no | employee_name | job_no | |
---|---|---|---|
00009999 | Dean | 002 |
This file contains 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
import pandas as pd | |
# Ensure they type of employee_no is a string. | |
df = pd.read_csv('read_csv_dtype.csv', dtype={'employee_no': str}) |
NewerOlder