简体   繁体   中英

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

   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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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