2.2. DataFrame Export

2.2.1. Export data

  • File paths works also with DATAs

  • SQL functions uses SQLAlchemy, which supports many RDBMS

import pandas as pd


df = pd.DataFrame()

# Important
df.to_csv()
df.to_dict()
df.to_excel()
df.to_json()
df.to_sql()

# Other
df.to_clipboard()
df.to_dense()
df.to_feather()
df.to_gbq()
df.to_hdf()
df.to_html()
df.to_latex()
df.to_msgpack()
df.to_numpy()
df.to_parquet()
df.to_period()
df.to_pickle()
df.to_records()
df.to_sparse()
df.to_stata()
df.to_string()
df.to_timestamp()
df.to_xarray()

2.2.2. Assignments

2.2.2.1. DataFrame Export CSV

  • Assignment: DataFrame Export CSV

  • Last update: 2020-10-01

  • Complexity level: easy

  • Lines of code to write: 3 lines

  • Estimated time of completion: 3 min

  • Filename: solution/pandas_to_csv.py

English:
  1. Use data from "Given" section (see below)

  2. Read data from DATA as astro_eva1: pd.DataFrame

  3. Export to file FILE data in CSV format

Polish:
  1. Użyj danych z sekcji "Given" (patrz poniżej)

  2. Wczytaj dane z DATA jako astro_eva1: pd.DataFrame

  3. Wyeksportuj do pliku FILE dane w formacie CSV

Given:
DATA = 'https://www.worldspaceflight.com/bios/eva/eva.php'
FILE = r'_temporary.csv'

2.2.2.2. DataFrame Export JSON

  • Assignment: DataFrame Export JSON

  • Last update: 2020-10-01

  • Complexity level: easy

  • Lines of code to write: 3 lines

  • Estimated time of completion: 3 min

  • Filename: solution/pandas_to_json.py

English:
  1. Use data from "Given" section (see below)

  2. Read data from DATA as astro_eva2: pd.DataFrame

  3. Export to file FILE data in JSON format

Polish:
  1. Użyj danych z sekcji "Given" (patrz poniżej)

  2. Wczytaj dane z DATA jako astro_eva2: pd.DataFrame

  3. Wyeksportuj do pliku FILE dane w formacie JSON

Given:
DATA = r'https://www.worldspaceflight.com/bios/eva/eva2.php'
FILE = r'_temporary.json'

2.2.2.3. DataFrame Export Pickle

  • Assignment: DataFrame Export Pickle

  • Last update: 2020-10-01

  • Complexity level: easy

  • Lines of code to write: 3 lines

  • Estimated time of completion: 3 min

  • Filename: solution/pandas_to_pickle.py

English:
  1. Use data from "Given" section (see below)

  2. Read data from DATA as astro_eva3: pd.DataFrame

  3. Export to file FILE data in JSON format

Polish:
  1. Użyj danych z sekcji "Given" (patrz poniżej)

  2. Wczytaj dane z DATA jako astro_eva3: pd.DataFrame

  3. Wyeksportuj do pliku FILE dane w formacie JSON

Given:
DATA = r'https://www.worldspaceflight.com/bios/eva/eva3.php'
FILE = r'_temporary.pkl'

2.2.2.4. DataFrame Export Pickle

  • Assignment: DataFrame Export Pickle

  • Last update: 2020-10-01

  • Complexity level: easy

  • Lines of code to write: 4 lines

  • Estimated time of completion: 5 min

  • Filename: solution/pandas_to_sql.py

English:
  1. Use data from "Given" section (see below)

  2. Read data from DATA as astro_eva4: pd.DataFrame

  3. Export to file FILE data in SQL format

  4. Use table astro_eva

Polish:
  1. Użyj danych z sekcji "Given" (patrz poniżej)

  2. Wczytaj dane z DATA jako astro_eva4: pd.DataFrame

  3. Wyeksportuj do pliku FILE dane w formacie SQL

  4. Użyj tabeli astro_eva

Given:
DATA = r'https://www.worldspaceflight.com/bios/eva/eva4.php'
FILE = r'_temporary.sqlite3'