<i id='ZGAXI'><tr id='ZGAXI'><dt id='ZGAXI'><q id='ZGAXI'><span id='ZGAXI'><b id='ZGAXI'><form id='ZGAXI'><ins id='ZGAXI'></ins><ul id='ZGAXI'></ul><sub id='ZGAXI'></sub></form><legend id='ZGAXI'></legend><bdo id='ZGAXI'><pre id='ZGAXI'><center id='ZGAXI'></center></pre></bdo></b><th id='ZGAXI'></th></span></q></dt></tr></i><div id='ZGAXI'><tfoot id='ZGAXI'></tfoot><dl id='ZGAXI'><fieldset id='ZGAXI'></fieldset></dl></div>
<tfoot id='ZGAXI'></tfoot>

  • <small id='ZGAXI'></small><noframes id='ZGAXI'>

        <bdo id='ZGAXI'></bdo><ul id='ZGAXI'></ul>
        <legend id='ZGAXI'><style id='ZGAXI'><dir id='ZGAXI'><q id='ZGAXI'></q></dir></style></legend>

        对 Pandas 数据集执行 SQL 查询

        时间:2023-10-10

        <tfoot id='WMcAH'></tfoot>
          <tbody id='WMcAH'></tbody>
        • <bdo id='WMcAH'></bdo><ul id='WMcAH'></ul>

              <small id='WMcAH'></small><noframes id='WMcAH'>

              <i id='WMcAH'><tr id='WMcAH'><dt id='WMcAH'><q id='WMcAH'><span id='WMcAH'><b id='WMcAH'><form id='WMcAH'><ins id='WMcAH'></ins><ul id='WMcAH'></ul><sub id='WMcAH'></sub></form><legend id='WMcAH'></legend><bdo id='WMcAH'><pre id='WMcAH'><center id='WMcAH'></center></pre></bdo></b><th id='WMcAH'></th></span></q></dt></tr></i><div id='WMcAH'><tfoot id='WMcAH'></tfoot><dl id='WMcAH'><fieldset id='WMcAH'></fieldset></dl></div>
                <legend id='WMcAH'><style id='WMcAH'><dir id='WMcAH'><q id='WMcAH'></q></dir></style></legend>

                  本文介绍了对 Pandas 数据集执行 SQL 查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个名为df"的 Pandas 数据集.

                  I have a pandas data set, called 'df'.

                  我该如何做类似下面的事情;

                  How can I do something like below;

                  df.query("select * from df")
                  

                  谢谢.

                  对于那些知道R的人来说,有一个叫做sqldf的库,你可以在R中执行SQL代码,我的问题基本上是,python中有没有像sqldf这样的库

                  For those who know R, there is a library called sqldf where you can execute SQL code in R, my question is basically, is there some library like sqldf in python

                  推荐答案

                  这不是什么 pandas.query 应该这样做.您可以查看包 pandasql(与 R 中的 sqldf 相同)

                  This is not what pandas.query is supposed to do. You can look at package pandasql (same like sqldf in R )

                  import pandas as pd
                  import pandasql as ps
                  
                  df = pd.DataFrame([[1234, 'Customer A', '123 Street', np.nan],
                                 [1234, 'Customer A', np.nan, '333 Street'],
                                 [1233, 'Customer B', '444 Street', '333 Street'],
                                [1233, 'Customer B', '444 Street', '666 Street']], columns=
                  ['ID', 'Customer', 'Billing Address', 'Shipping Address'])
                  
                  q1 = """SELECT ID FROM df """
                  
                  print(ps.sqldf(q1, locals()))
                  
                       ID
                  0  1234
                  1  1234
                  2  1233
                  3  1233
                  


                  更新 2020-07-10

                  更新pandasql

                  ps.sqldf("select * from df")
                  

                  这篇关于对 Pandas 数据集执行 SQL 查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:LINQ 与 SQLite (linqtosql) 下一篇:什么是 sqlite 的好的 OO C++ 包装器

                  相关文章

                  <small id='G9okF'></small><noframes id='G9okF'>

                1. <tfoot id='G9okF'></tfoot>
                  • <bdo id='G9okF'></bdo><ul id='G9okF'></ul>

                    1. <i id='G9okF'><tr id='G9okF'><dt id='G9okF'><q id='G9okF'><span id='G9okF'><b id='G9okF'><form id='G9okF'><ins id='G9okF'></ins><ul id='G9okF'></ul><sub id='G9okF'></sub></form><legend id='G9okF'></legend><bdo id='G9okF'><pre id='G9okF'><center id='G9okF'></center></pre></bdo></b><th id='G9okF'></th></span></q></dt></tr></i><div id='G9okF'><tfoot id='G9okF'></tfoot><dl id='G9okF'><fieldset id='G9okF'></fieldset></dl></div>
                      <legend id='G9okF'><style id='G9okF'><dir id='G9okF'><q id='G9okF'></q></dir></style></legend>