-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pandas.html
68 lines (66 loc) · 29.6 KB
/
Pandas.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- common.css -->
<style>* {-webkit-tap-highlight-color: rgba(0,0,0,0);}html {-webkit-text-size-adjust: none;}body {font-family: -apple-system, Helvetica, Arial, sans-serif;margin: 0;padding: 20px;color: #333;word-wrap: break-word;}h1, h2, h3, h4, h5, h6 {line-height: 1.1;}img {max-width: 100% !important;height: auto;}blockquote {margin: 0;padding: 0 15px;color: #777;border-left: 4px solid #ddd;}hr {background-color: #ddd;border: 0;height: 1px;margin: 15px 0;}code {font-family: Menlo, Consolas, 'Ubuntu Mono', Monaco, 'source-code-pro', monospace;line-height: 1.4;margin: 0;padding: 0.2em 0;font-size: 90%;background-color: rgba(0,0,0,0.04);border-radius: 3px;}pre > code {margin: 0;padding: 0;font-size: 100%;word-break: normal;background: transparent;border: 0;}ol {list-style-type: decimal;}ol ol, ul ol {list-style-type: lower-latin;}ol ol ol, ul ol ol, ul ul ol, ol ul ol {list-style-type: lower-roman;}table {border-spacing: 0;border-collapse: collapse;margin-top: 0;margin-bottom: 16px;}table th {font-weight: bold;}table th, table td {padding: 6px 13px;border: 1px solid #ddd;}table tr {border-top: 1px solid #ccc;}table tr:nth-child(even) {background-color: #f8f8f8;}input[type="checkbox"] {cursor: default;margin-right: 0.5em;font-size: 13px;}.task-list-item {list-style-type: none;}.task-list-item+.task-list-item {margin-top: 3px;}.task-list-item input {float: left;margin: 0.3em 1em 0.25em -1.6em;vertical-align: middle;}#tag-field {margin: 8px 2px 10px;}#tag-field .tag {display: inline-block;background: #cadff3;border-radius: 4px;padding: 1px 8px;color: black;font-size: 12px;margin-right: 10px;line-height: 1.4;}</style>
<!-- ace-static.css -->
<style>.ace_static_highlight {white-space: pre-wrap;}.ace_static_highlight .ace_gutter {width: 2em;text-align: right;padding: 0 3px 0 0;margin-right: 3px;}.ace_static_highlight.ace_show_gutter > .ace_line {padding-left: 2.6em;}.ace_static_highlight .ace_line {position: relative;}.ace_static_highlight .ace_gutter-cell {-moz-user-select: -moz-none;-khtml-user-select: none;-webkit-user-select: none;user-select: none;top: 0;bottom: 0;left: 0;position: absolute;}.ace_static_highlight .ace_gutter-cell:before {content: counter(ace_line, decimal);counter-increment: ace_line;}.ace_static_highlight {counter-reset: ace_line;}</style>
<style>.ace-chrome .ace_gutter {background: #ebebeb;color: #333;overflow : hidden;}.ace-chrome .ace_print-margin {width: 1px;background: #e8e8e8;}.ace-chrome {background-color: #FFFFFF;color: black;}.ace-chrome .ace_cursor {color: black;}.ace-chrome .ace_invisible {color: rgb(191, 191, 191);}.ace-chrome .ace_constant.ace_buildin {color: rgb(88, 72, 246);}.ace-chrome .ace_constant.ace_language {color: rgb(88, 92, 246);}.ace-chrome .ace_constant.ace_library {color: rgb(6, 150, 14);}.ace-chrome .ace_invalid {background-color: rgb(153, 0, 0);color: white;}.ace-chrome .ace_fold {}.ace-chrome .ace_support.ace_function {color: rgb(60, 76, 114);}.ace-chrome .ace_support.ace_constant {color: rgb(6, 150, 14);}.ace-chrome .ace_support.ace_type,.ace-chrome .ace_support.ace_class.ace-chrome .ace_support.ace_other {color: rgb(109, 121, 222);}.ace-chrome .ace_variable.ace_parameter {font-style:italic;color:#FD971F;}.ace-chrome .ace_keyword.ace_operator {color: rgb(104, 118, 135);}.ace-chrome .ace_comment {color: #236e24;}.ace-chrome .ace_comment.ace_doc {color: #236e24;}.ace-chrome .ace_comment.ace_doc.ace_tag {color: #236e24;}.ace-chrome .ace_constant.ace_numeric {color: rgb(0, 0, 205);}.ace-chrome .ace_variable {color: rgb(49, 132, 149);}.ace-chrome .ace_xml-pe {color: rgb(104, 104, 91);}.ace-chrome .ace_entity.ace_name.ace_function {color: #0000A2;}.ace-chrome .ace_heading {color: rgb(12, 7, 255);}.ace-chrome .ace_list {color:rgb(185, 6, 144);}.ace-chrome .ace_marker-layer .ace_selection {background: rgb(181, 213, 255);}.ace-chrome .ace_marker-layer .ace_step {background: rgb(252, 255, 0);}.ace-chrome .ace_marker-layer .ace_stack {background: rgb(164, 229, 101);}.ace-chrome .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid rgb(192, 192, 192);}.ace-chrome .ace_marker-layer .ace_active-line {background: rgba(0, 0, 0, 0.07);}.ace-chrome .ace_gutter-active-line {background-color : #dcdcdc;}.ace-chrome .ace_marker-layer .ace_selected-word {background: rgb(250, 250, 255);border: 1px solid rgb(200, 200, 250);}.ace-chrome .ace_storage,.ace-chrome .ace_keyword,.ace-chrome .ace_meta.ace_tag {color: rgb(147, 15, 128);}.ace-chrome .ace_string.ace_regex {color: rgb(255, 0, 0)}.ace-chrome .ace_string {color: #1A1AA6;}.ace-chrome .ace_entity.ace_other.ace_attribute-name {color: #994409;}.ace-chrome .ace_indent-guide {background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==") right repeat-y;}</style>
<!-- export.css -->
<style>
body{margin:0 auto;max-width:800px;line-height:1.4}
#nav{margin:5px 0 10px;font-size:15px}
#titlearea{border-bottom:1px solid #ccc;font-size:17px;padding:10px 0;}
#contentarea{font-size:15px;margin:16px 0}
.cell{outline:0;min-height:20px;margin:5px 0;padding:5px 0;}
.code-cell{font-family:Menlo,Consolas,'Ubuntu Mono',Monaco,'source-code-pro',monospace;font-size:12px;}
.latex-cell{white-space:pre-wrap;}
</style>
<!-- User CSS -->
<style> .text-cell {font-size: 15px;}.code-cell {font-size: 12px;}.markdown-cell {font-size: 15px;}.latex-cell {font-size: 15px;}</style>
</head>
<body>
<div id="nav"><div>Next: <a href='MongoDB.html'>MongoDB</a>, Previous: <a href='Jupyter Notebook.html'>Jupyter Notebook</a>, Up: <a href='index.html'>Index</a></div></div>
<div id="titlearea">
<h2>Pandas</h2>
</div>
<div id="contentarea"><div class="cell text-cell"><div><br></div><div><br></div></div><div class="cell text-cell"><a href="http://songhuiming.github.io/pages/2017/04/02/jupyter-and-pandas-display/">http://songhuiming.github.io/pages/2017/04/02/jupyter-and-pandas-display/</a></div><div class="cell code-cell"><div class="ace-chrome"><div class="ace_static_highlight ace_show_gutter" style="counter-reset:ace_line 0"><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">pd</span>.<span class="ace_identifier">set_option</span><span class="ace_paren ace_lparen">(</span><span class="ace_string ace_start">'</span><span class="ace_string">display.height</span><span class="ace_string ace_end">'</span>, <span class="ace_constant ace_numeric">1000</span><span class="ace_paren ace_rparen">)</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">pd</span>.<span class="ace_identifier">set_option</span><span class="ace_paren ace_lparen">(</span><span class="ace_string ace_start">'</span><span class="ace_string">display.max_rows</span><span class="ace_string ace_end">'</span>, <span class="ace_constant ace_numeric">500</span><span class="ace_paren ace_rparen">)</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">pd</span>.<span class="ace_identifier">set_option</span><span class="ace_paren ace_lparen">(</span><span class="ace_string ace_start">'</span><span class="ace_string">display.max_columns</span><span class="ace_string ace_end">'</span>, <span class="ace_constant ace_numeric">500</span><span class="ace_paren ace_rparen">)</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">pd</span>.<span class="ace_identifier">set_option</span><span class="ace_paren ace_lparen">(</span><span class="ace_string ace_start">'</span><span class="ace_string">display.width</span><span class="ace_string ace_end">'</span>, <span class="ace_constant ace_numeric">1000</span><span class="ace_paren ace_rparen">)</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_comment"># to show all records in jupyternotebook</span>
</div></div></div></div><div class="cell text-cell"></div><div class="cell text-cell"><a href="http://www.gregreda.com/2013/10/26/working-with-pandas-dataframes/">http://www.gregreda.com/2013/10/26/working-with-pandas-dataframes/</a></div><div class="cell text-cell">Tips:<div>Pandas Ufuncs and why they are so much better than apply command<br></div><div><span style="color: rgba(0, 0, 0, 0.843137); font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-variant-ligatures: normal; letter-spacing: -0.063px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);">Note that </span><span class="markup--strong markup--p-strong" style="font-weight: 700; color: rgba(0, 0, 0, 0.843137); font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-variant-ligatures: normal; letter-spacing: -0.063px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);">apply</span><span style="color: rgba(0, 0, 0, 0.843137); font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-variant-ligatures: normal; letter-spacing: -0.063px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);"> is just a little bit faster than a </span><span class="markup--strong markup--p-strong" style="font-weight: 700; color: rgba(0, 0, 0, 0.843137); font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-variant-ligatures: normal; letter-spacing: -0.063px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);">python for loop</span><span style="color: rgba(0, 0, 0, 0.843137); font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-variant-ligatures: normal; letter-spacing: -0.063px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);">! That’s why it is most recommended using pandas builtin </span><a href="https://docs.scipy.org/doc/numpy/reference/ufuncs.html" data-href="https://docs.scipy.org/doc/numpy/reference/ufuncs.html" class="markup--anchor markup--p-anchor" rel="nofollow noopener" target="_blank" style="background-color: rgb(255, 255, 255); color: inherit; text-decoration: none; background-image: linear-gradient(rgba(0, 0, 0, 0.682353) 50%, rgba(0, 0, 0, 0) 50%); background-size: 2px 0.1em; font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-variant-ligatures: normal; letter-spacing: -0.063px; orphans: 2; widows: 2; background-position: 0px 1.07em; background-repeat: repeat no-repeat;"><span class="markup--strong markup--p-strong" style="font-weight: 700;">ufuncs</span></a><span class="markup--strong markup--p-strong" style="font-weight: 700; color: rgba(0, 0, 0, 0.843137); font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-variant-ligatures: normal; letter-spacing: -0.063px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);"> </span><span style="color: rgba(0, 0, 0, 0.843137); font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-variant-ligatures: normal; letter-spacing: -0.063px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);">for applying preprocessing tasks on columns</span><br></div></div><div class="cell code-cell"><div class="ace-chrome"><div class="ace_static_highlight ace_show_gutter" style="counter-reset:ace_line 0"><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">df</span>.<span class="ace_identifier">groupby</span><span class="ace_paren ace_lparen">(</span><span class="ace_string">'name'</span><span class="ace_paren ace_rparen">)</span><span class="ace_paren ace_lparen">[</span><span class="ace_string">'activity'</span><span class="ace_paren ace_rparen">]</span>.<span class="ace_identifier">value_counts</span><span class="ace_paren ace_lparen">(</span><span class="ace_paren ace_rparen">)</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">df</span>.<span class="ace_identifier">groupby</span><span class="ace_paren ace_lparen">(</span><span class="ace_string">'name'</span><span class="ace_paren ace_rparen">)</span><span class="ace_paren ace_lparen">[</span><span class="ace_string">'activity'</span><span class="ace_paren ace_rparen">]</span>.<span class="ace_identifier">value_counts</span><span class="ace_paren ace_lparen">(</span><span class="ace_paren ace_rparen">)</span>.<span class="ace_identifier">unstack</span><span class="ace_paren ace_lparen">(</span><span class="ace_paren ace_rparen">)</span>.<span class="ace_identifier">fillna</span><span class="ace_paren ace_lparen">(</span><span class="ace_constant ace_numeric">0</span><span class="ace_paren ace_rparen">)</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_comment">#By doing unstack we are transforming the last level of the index to the columns.</span>
</div></div></div></div><div class="cell text-cell"><img src="resources/7E2ED9B3E87F072076CF57C80FDC5347.jpg" width="594" height="484"></div><div class="cell code-cell"><div class="ace-chrome"><div class="ace_static_highlight ace_show_gutter" style="counter-reset:ace_line 0"><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">df</span> <span class="ace_keyword ace_operator">=</span> <span class="ace_identifier">df</span>.<span class="ace_identifier">sort_values</span><span class="ace_paren ace_lparen">(</span><span class="ace_identifier">by</span><span class="ace_keyword ace_operator">=</span><span class="ace_paren ace_lparen">[</span><span class="ace_string">'name'</span>,<span class="ace_string">'timestamp'</span><span class="ace_paren ace_rparen">])</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">df</span><span class="ace_paren ace_lparen">[</span><span class="ace_string">'time_diff'</span><span class="ace_paren ace_rparen">]</span> <span class="ace_keyword ace_operator">=</span> <span class="ace_identifier">df</span><span class="ace_paren ace_lparen">[</span><span class="ace_string">'timestamp'</span><span class="ace_paren ace_rparen">]</span>.<span class="ace_identifier">diff</span><span class="ace_paren ace_lparen">(</span><span class="ace_paren ace_rparen">)</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">df</span>.<span class="ace_identifier">loc</span><span class="ace_paren ace_lparen">[</span><span class="ace_identifier">df</span>.<span class="ace_identifier">name</span> <span class="ace_keyword ace_operator">!=</span> <span class="ace_identifier">df</span>.<span class="ace_identifier">name</span>.<span class="ace_identifier">shift</span><span class="ace_paren ace_lparen">(</span><span class="ace_paren ace_rparen">)</span>, <span class="ace_string">'time_diff'</span><span class="ace_paren ace_rparen">]</span> <span class="ace_keyword ace_operator">=</span> <span class="ace_constant ace_language">None</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_comment"># BTW the useful .Shift command shift all the column down per one space, so we can see on which row this column is changing by doing this: df.name!=df.name.shift().</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_comment"># And .loc command is the most recommended way to set values for a column for specific indices.</span>
</div></div></div></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"><p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);">Tips-Pandas</p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69); min-height: 14px;"><br></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);"><b>reading multiple data files using a loop</b></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);"><img src="resources/21E83BACD7F1618FCA38F0DD988DBB0C.jpg" alt="Pasted Graphic 3.tiff" width="459" height="354"></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);"><b>Sorting DataFrame with the Index & columns</b></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);"><img src="resources/3B1A6953BCD2E9600361F453599FBB4F.jpg" alt="Pasted Graphic.tiff" width="675" height="632"></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);"><b>Reindexing using another DataFrame Index</b></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);"><img src="resources/11E87FF3BC1E14BB5BBEF9EF2BC47C13.jpg" alt="Pasted Graphic 1.tiff" width="594" height="561"></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);"><b>Arithmetic with Series & DataFrames</b></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);"><img src="resources/D6102986B65C3CC948462AE5CA699D72.jpg" alt="Pasted Graphic 3_1.tiff" width="458" height="253"></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);"><img src="resources/80E894E0FCA52AEC930D4479FFA45F35.jpg" alt="Pasted Graphic 4.tiff" width="444" height="182"></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);"><img src="resources/DEFEF0A84695784A4ED5BD7E8D93EE13.jpg" alt="Pasted Graphic 2.tiff" width="344" height="233"></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69); min-height: 14px;"><br></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);"><img src="resources/F90DE34C8B59BD702CEF32816AC7A96D.jpg" alt="Pasted Graphic 5.tiff" width="718" height="442"></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);"><img src="resources/0E6C399AD0BC242593FB66977A7F6803.jpg" alt="Pasted Graphic 6.tiff" width="155" height="196"></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);"><img src="resources/DF9104601BB6792C1C09515A5E4A1994.jpg" alt="Pasted Graphic 7.tiff" width="1124" height="604"></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69); min-height: 14px;"><br></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);"><img src="resources/E1ABB3FBCC81E654294B4105EC33BF29.jpg" alt="Pasted Graphic 8.tiff" width="957" height="471"></p>
<p style="margin: 8px 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);"><img src="resources/6D1FD4A3E1C476F8813D162DEFBB3565.jpg" alt="Pasted Graphic 9.tiff" width="1230" height="466"></p><div><br></div></div><div class="cell text-cell"><h1 style="font-family: Arial, sans-serif; background-color: rgb(190, 212, 235); font-weight: normal; color: rgb(33, 34, 36); margin: 0px 0px 10px; padding: 5px 0px 5px 10px; text-shadow: white 0px 1px 0px; border-top-width: 20px; border-top-style: solid; border-top-color: white; font-size: 28.8px; font-variant-ligatures: normal; orphans: 2; widows: 2;">pandas.read_json<a class="headerlink" href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_json.html#pandas-read-json" title="Permalink to this headline" style="color: rgb(198, 15, 15); text-decoration: none; visibility: hidden; font-size: 0.8em; padding: 0px 4px;"></a></h1><dl class="function" style="margin-bottom: 15px; color: rgb(62, 67, 73); font-family: Arial, sans-serif; font-size: 14.4px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);"><dt id="pandas.read_json"><code class="descclassname" style="background-color: transparent;">pandas.</code><code class="descname" style="background-color: transparent; font-weight: bold; font-size: 1.2em;">read_json</code><span class="sig-paren" style="font-size: larger;">(</span><em>path_or_buf=None</em>, <em>orient=None</em>, <em>typ='frame'</em>, <em>dtype=True</em>, <em>convert_axes=True</em>, <em>convert_dates=True</em>, <em>keep_default_dates=True</em>, <em>numpy=False</em>, <em>precise_float=False</em>, <em>date_unit=None</em>, <em>encoding=None</em>, <em>lines=False</em><span class="sig-paren" style="font-size: larger;">)</span><a class="reference external" href="http://github.com/pandas-dev/pandas/blob/v0.20.3/pandas/io/json/json.py#L172-L363" style="color: rgb(0, 91, 129); text-decoration: none;"><span class="viewcode-link" style="float: right;">[source]</span></a><a class="headerlink" href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_json.html#pandas.read_json" title="Permalink to this definition" style="color: rgb(198, 15, 15); text-decoration: none; visibility: hidden; font-size: 0.8em; padding: 0px 4px;"></a></dt><dd style="margin-top: 3px; margin-bottom: 10px; margin-left: 30px; hyphens: auto; line-height: 1.5em;"><p style="margin-top: 0px; hyphens: auto; line-height: 1.5em;">Convert a JSON string to pandas object</p><table class="docutils field-list" frame="void" rules="none" style="margin-bottom: 10px; border: 0px; border-collapse: separate; border-spacing: 10px; margin-left: 1px;"><colgroup><col class="field-name"><col class="field-body"></colgroup><tbody valign="top"><tr class="field-odd field" style="vertical-align: middle; padding: 0.5em; line-height: normal; max-width: none; border: none; background-color: rgb(245, 245, 245); background-position: initial initial; background-repeat: initial initial;"><th class="field-name" style="padding: 1px 8px 1px 5px; vertical-align: middle; line-height: normal; white-space: nowrap; max-width: none; background-color: rgb(238, 238, 238); border: 0px !important;">Parameters:</th><td class="field-body" style="vertical-align: middle; padding: 1px 8px 1px 5px; line-height: normal; max-width: none; border: 0px !important;"><p class="first" style="margin: 0px; hyphens: auto; line-height: 1.5em; font-style: italic;"><strong style="font-style: normal;">path_or_buf</strong> : a valid JSON string or file-like, default: None</p><blockquote style="hyphens: auto; border-left: none; margin: 0em 0em 0.3em; padding-left: 30px;"><p style="margin: 0px; hyphens: auto; line-height: 1.5em;">The string could be a URL. Valid URL schemes include http, ftp, s3, and file. For file URLs, a host is expected. For instance, a local file could be <code class="docutils literal"><span class="pre">file://localhost/path/to/table.json</span></code></p></blockquote><p style="margin: 0px; hyphens: auto; line-height: 1.5em; font-style: italic;"><strong style="font-style: normal;">orient</strong> : string,</p><blockquote style="hyphens: auto; border-left: none; margin: 0em 0em 0.3em; padding-left: 30px;"><p style="margin: 0px; hyphens: auto; line-height: 1.5em;">Indication of expected JSON string format. Compatible JSON strings can be produced by <code class="docutils literal"><span class="pre">to_json()</span></code> with a corresponding orient value. The set of possible orients is:</p><ul class="simple" style="margin: 0px; padding-left: 1em;"><li style="hyphens: auto; line-height: 1.5em;"><code class="docutils literal"><span class="pre">'split'</span></code> : dict like <code class="docutils literal"><span class="pre">{index</span> <span class="pre">-></span> <span class="pre">[index],</span> <span class="pre">columns</span> <span class="pre">-></span> <span class="pre">[columns],</span> <span class="pre">data</span> <span class="pre">-></span><span class="pre">[values]}</span></code></li><li style="hyphens: auto; line-height: 1.5em;"><code class="docutils literal"><span class="pre">'records'</span></code> : list like <code class="docutils literal"><span class="pre">[{column</span> <span class="pre">-></span> <span class="pre">value},</span> <span class="pre">...</span> <span class="pre">,</span> <span class="pre">{column</span> <span class="pre">-></span> <span class="pre">value}]</span></code></li><li style="hyphens: auto; line-height: 1.5em;"><code class="docutils literal"><span class="pre">'index'</span></code> : dict like <code class="docutils literal"><span class="pre">{index</span> <span class="pre">-></span> <span class="pre">{column</span> <span class="pre">-></span> <span class="pre">value}}</span></code></li><li style="hyphens: auto; line-height: 1.5em;"><code class="docutils literal"><span class="pre">'columns'</span></code> : dict like <code class="docutils literal"><span class="pre">{column</span> <span class="pre">-></span> <span class="pre">{index</span> <span class="pre">-></span> <span class="pre">value}}</span></code></li><li style="hyphens: auto; line-height: 1.5em;"><code class="docutils literal"><span class="pre">'values'</span></code> : just the values array</li></ul><p style="margin: 0px; hyphens: auto; line-height: 1.5em;">The allowed and default values depend on the value of the <cite>typ</cite> parameter.</p><ul class="simple" style="margin: 0px; padding-left: 1em;"><li style="hyphens: auto; line-height: 1.5em;">when <code class="docutils literal"><span class="pre">typ</span> <span class="pre">==</span> <span class="pre">'series'</span></code>,<ul style="margin: 0px; padding-left: 1em;"><li style="hyphens: auto; line-height: 1.5em;">allowed orients are <code class="docutils literal"><span class="pre">{'split','records','index'}</span></code></li><li style="hyphens: auto; line-height: 1.5em;">default is <code class="docutils literal"><span class="pre">'index'</span></code></li><li style="hyphens: auto; line-height: 1.5em;">The Series index must be unique for orient <code class="docutils literal"><span class="pre">'index'</span></code>.</li></ul></li><li style="hyphens: auto; line-height: 1.5em;">when <code class="docutils literal"><span class="pre">typ</span> <span class="pre">==</span> <span class="pre">'frame'</span></code>,<ul style="margin: 0px; padding-left: 1em;"><li style="hyphens: auto; line-height: 1.5em;">allowed orients are <code class="docutils literal"><span class="pre">{'split','records','index',</span> <span class="pre">'columns','values'}</span></code></li><li style="hyphens: auto; line-height: 1.5em;">default is <code class="docutils literal"><span class="pre">'columns'</span></code></li><li style="hyphens: auto; line-height: 1.5em;">The DataFrame index must be unique for orients <code class="docutils literal"><span class="pre">'index'</span></code> and <code class="docutils literal"><span class="pre">'columns'</span></code>.</li><li style="hyphens: auto; line-height: 1.5em;">The DataFrame columns must be unique for orients <code class="docutils literal"><span class="pre">'index'</span></code>, <code class="docutils literal"><span class="pre">'columns'</span></code>, and <code class="docutils literal"><span class="pre">'records'</span></code>.</li></ul></li></ul></blockquote><p style="margin: 0px; hyphens: auto; line-height: 1.5em; font-style: italic;"><strong style="font-style: normal;">typ</strong> : type of object to recover (series or frame), default ‘frame’</p><p style="margin: 0px; hyphens: auto; line-height: 1.5em; font-style: italic;"><strong style="font-style: normal;">dtype</strong> : boolean or dict, default True</p><blockquote style="hyphens: auto; border-left: none; margin: 0em 0em 0.3em; padding-left: 30px;"><p style="margin: 0px; hyphens: auto; line-height: 1.5em;">If True, infer dtypes, if a dict of column to dtype, then use those, if False, then don’t infer dtypes at all, applies only to the data.</p></blockquote></td></tr></tbody></table></dd></dl></div></div>
<script>document.body.onkeyup = function(e) {
if (e.keyCode === 39) window.location.href = 'MongoDB.html';
if (e.keyCode === 37) window.location.href = 'Jupyter Notebook.html';
}</script>
</body>
</html>