22 lines
695 B
Python
22 lines
695 B
Python
"""
|
|
Read an online CSV file into a DataFrame.
|
|
|
|
Since the referenced file contains a datetime column, and by default
|
|
read_csv does not interpret data from the text file, you have to replace
|
|
some columns with their conversion as a correct dtype.
|
|
|
|
Or better, you can directly tell the read_csv function to interpret
|
|
|
|
"""
|
|
import pandas as pd
|
|
|
|
|
|
url = "https://media.githubusercontent.com/media/datablist/sample-csv-files/main/files/customers/customers-100.csv"
|
|
df = pd.read_csv(url, parse_dates=["Subscription Date"])
|
|
print(df.to_string(max_cols=7))
|
|
print(df.dtypes)
|
|
|
|
# Remplacer une colonne avec une conversionl
|
|
df["Subscription Date"] = pd.to_datetime(df["Subscription Date"])
|
|
print(df, df.dtypes)
|