Skip to content

Instantly share code, notes, and snippets.

View ChaitanyaBaweja's full-sized avatar

Chaitanya Baweja ChaitanyaBaweja

View GitHub Profile
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
# 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))
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
# 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())
total_input = []
print("Enter Student Names: ")
while True:
name = input()
if name:
total_input.append(name)
else:
break
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))
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)
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)
try:
num = int(input('Enter a number: '))
print('Good job. The entered number is: ', num)
except ValueError:
print('This is not a number.')
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)