Created
July 10, 2020 08:08
-
-
Save ChaitanyaBaweja/968ff8f454a68be87c7efcfc73eeacd1 to your computer and use it in GitHub Desktop.
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 | |
# apply make_int function to the entire series using map | |
df['Salary'] = df['Salary'].map(make_int) | |
print(df['Salary'].head()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment