Skip to content

Instantly share code, notes, and snippets.

@FlameWert
Created February 5, 2020 05:08
Show Gist options
  • Save FlameWert/881e371ec83535db862305295c0ccdfc to your computer and use it in GitHub Desktop.
Save FlameWert/881e371ec83535db862305295c0ccdfc to your computer and use it in GitHub Desktop.
Pickle and Unpickle in Python
import pandas as pd
import pickle
browser_market_share = {
"Date": "2020-01",
"Chrome": 64.1,
"Safari": 17.21,
"Firefox": 4.7,
"Samsung Internet": 3.33,
"UC Browser": 2.61,
"Opera": 2.26,
"IE": 1.68,
"Edge": 2.17,
"Android": 0.54,
"KaiOS": 0.11,
"Yandex Browser": 0.27,
"QQ Browser": 0.26,
"Puffin": 0.14,
"Coc Coc": 0.09,
"Chromium": 0.08,
"IEMobile": 0.05,
"Whale Browser": 0.09,
"Sogou Explorer": 0.05,
"Sony PS4": 0.05,
"mCent": 0,
"Mozilla": 0.08,
"Maxthon": 0.03,
"Vivaldi": 0.01,
"360 Safe Browser": 0.02,
"Unknown": 0.01,
"BlackBerry": 0.01,
"Nokia": 0,
"Pale Moon": 0.01,
"Other": 0.04
}
with open('browser_market_share.pkl', 'wb') as file_object: #w - write, b - binary
pickle.dump(browser_market_share, file_object)
with open('browser_market_share.pkl', 'rb') as file_object:
new_data = pickle.load(file_object)
print(new_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment