import pandas as pd
import pandas_profiling
import numpy as np

"""
Explanation: pandas-profiling Meteorites example
Source of data: https://data.nasa.gov/Space-Science/Meteorite-Landings/gh4g-9sfh
Import libraries
End of explanation
"""


df=pd.read_csv("examples/Meteorite_Landings.csv", parse_dates=['year'], encoding='UTF-8')

# Note: Pandas does not support dates before 1880, so we ignore these for this analysis
df['year'] = pd.to_datetime(df['year'], errors='coerce')

# Example: Constant variable
df['source'] = "NASA"

# Example: Boolean variable
df['boolean'] = np.random.choice([True, False], df.shape[0])

# Example: Mixed with base types
df['mixed'] = np.random.choice([1, "A"], df.shape[0])

# Example: Highly correlated variables
df['reclat_city'] = df['reclat'] + np.random.normal(scale=5,size=(len(df)))

# Example: Duplicate observations
duplicates_to_add = pd.DataFrame(df.iloc[0:10])
duplicates_to_add[u'name'] = duplicates_to_add[u'name'] + " copy"

df = df.append(duplicates_to_add, ignore_index=True)

"""
Explanation: Load and prepare example dataset
We add some fake variables for illustrating pandas-profiling capabilities
End of explanation
"""


pandas_profiling.ProfileReport(df)

"""
Explanation: Inline report without saving object
End of explanation
"""


pfr = pandas_profiling.ProfileReport(df)
pfr.to_file("/tmp/example.html")

"""
Explanation: Save report to file
End of explanation
"""


pfr

"""
Explanation: Print existing ProfileReport object inline
End of explanation
"""


