Untitled

mail@pastecode.io avatar
unknown
python
a month ago
706 B
2
Indexable
Never
import pandas as pd

# Read the dataframe from URL
url = input()
df = pd.read_csv(url)

# Delete rows with more than 50% missing values
df = df.dropna(thresh=len(df.columns) / 2)

# Remove character from the 'Date' column
df['Date'] = df['Date'].str.replace('é', '')

# Round off all float columns to two decimal places
float_columns = df.select_dtypes(include=['float']).columns
df[float_columns] = df[float_columns].round(2)

# Print number of rows and columns in the final dataframe
print(len(df))
print(len(df.columns))

# Print first 10 values of the 'Date' column
print(df['Date'].head(10).tolist())

# Print first 5 rows with only the float columns
print(df.select_dtypes(include=['float']).head())
Leave a Comment