简体   繁体   English

从熊猫数据框中提取单个元素

[英]extracting individual element from pandas data frame

I have saved the following panda file into CSV now how do I get it back as a panda file(dataframe) in another program.And is it possible to get single element from the dataframe like for example I want the element of 10th row 3rd column specifically like how it can be done in numpy我已将以下熊猫文件保存到 CSV 中,现在如何将其作为另一个程序中的熊猫文件(数据框)取回。是否可以从数据框中获取单个元素,例如我想要第 10 行第 3 列的元素特别喜欢它如何在 numpy 中完成

   df = af.merge(df, on='DateTime', how='left').interpolate()
   print(df)
   df.to_csv("my_csvfilename.csv")

I get the output我得到输出

         DateTime            pop
    0    2011-01-01  627000.000000
    1    2011-01-02  627024.657534
    2    2011-01-03  627049.315068
    3    2011-01-04  627073.972603
    4    2011-01-05  627098.630137
    ...         ...            ...
    3648 2020-12-27  713000.000000
    3649 2020-12-28  713000.000000
    3650 2020-12-29  713000.000000
    3651 2020-12-30  713000.000000
    3652 2020-12-31  713000.000000

Others have suggested how to extract specific elements above but retrieving the file in the first place should be as simple as其他人建议如何提取上面的特定元素,但首先检索文件应该像

  import pandas as pd
  df=pd.read_csv("my_csvfilename.csv")

If you aren't in the same directory you may need to amend to be如果您不在同一目录中,则可能需要修改为

  df=pd.read_csv(r"C:\directory\my_csvfilename.csv")

But obviously you need the correct path to the directory (eg C:\\My folder\\My subfolder)但显然您需要正确的目录路径(例如 C:\\My folder\\My subfolder)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM