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
import pandas as pd | |
missing_value_formats = ["n.a.","?","NA","n/a", "na", "--"] | |
df = pd.read_csv("employees.csv", na_values = missing_value_formats) | |
def make_int(i): | |
try: | |
return int(i) | |
except: | |
return pd.np.nan |
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
# a list with all missing value formats | |
missing_value_formats = ["n.a.","?","NA","n/a", "na", "--"] | |
df = pd.read_csv("employees.csv", na_values = missing_value_formats) | |
#print gender again | |
print(df['Gender'].head(10)) |
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 Name Gender Salary Bonus % Senior Management Team | |
0 Douglas Male 97308 6.945 TRUE Marketing | |
1 Thomas Male 61933 NaN TRUE NaN | |
2 Maria Female 130590 11.858 FALSE Finance | |
3 Jerry Male NaN 9.34 TRUE Finance | |
4 Larry Male 101004 1.389 TRUE Client Services |
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
# Importing libraries | |
import pandas as pd | |
import numpy as np | |
# Read csv file into a pandas dataframe | |
df = pd.read_csv("employees.csv") | |
# Prints out the first few rows | |
print(df.head()) |
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
total_input = [] | |
print("Enter Student Names: ") | |
while True: | |
name = input() | |
if name: | |
total_input.append(name) | |
else: | |
break |
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
entered_list = input("Enter a list of numbers separated by space: ").split() | |
print('Intermediate_list: ',entered_list) | |
num_list = list(map(int,entered_list)) | |
print('Number List: ',num_list) | |
print('List sum:', sum(num_list)) |
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
name, age, score = input("Enter student's name, age and score separated by space:").split() | |
print("Student Name:", name) | |
print("Student Age:", age) | |
print("Student Score:", score) |
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
while True: | |
try: | |
num = int(input('Enter a number: ')) | |
break | |
except ValueError: | |
print('Invalid Input. Try again.') | |
print('Good job. The entered number is: ', num) |
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
try: | |
num = int(input('Enter a number: ')) | |
print('Good job. The entered number is: ', num) | |
except ValueError: | |
print('This is not a number.') |
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
float_1 = float(input("Enter value: ")) | |
print('Type of float_1:',type(float_1)) | |
result = float_1*2 | |
print("Twice the given numbers is : ", result) |