0
import pandas as pd 
tbl1 = pd.import_csv('sample_prices.csv') 
tbl1.print()

and still not receiving anything? It does not even come up with an error.

martineau
  • 119,623
  • 25
  • 170
  • 301
KeyError
  • 5
  • 3
  • Does this resolve your issue? https://stackoverflow.com/questions/14365542/import-csv-file-as-a-pandas-dataframe – Matthew Wisdom Feb 08 '22 at 01:50
  • 2
    `import_csv()` is not an actual pandas function, as far as I can see. Please post your real code. – John Gordon Feb 08 '22 at 02:01
  • `import` has [special meaning](https://docs.python.org/3/reference/simple_stmts.html#import) in Python, so please don't use it to mean something else like using data produced by another application. – martineau Feb 08 '22 at 02:18

3 Answers3

0

The code might be written this way.

import pandas as pd
tbl1 = pd.read_csv('sample_prices.csv')
print(tbl1)
Nur Imtiazul Haque
  • 383
  • 1
  • 2
  • 10
  • While this code may answer the question, it would be better to include some context, explaining _how_ it works and _when_ to use it. Code-only answers are not useful in the long run. – martineau Feb 08 '22 at 02:11
  • That solved it. Cheers man. – KeyError Feb 08 '22 at 07:07
0

It should be writed like this

import pandas as pd

tbl1 = pd.read_csv('sample_prices.csv')
print(tbl1)
Jiu_Zou
  • 463
  • 1
  • 4
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 08 '22 at 02:09
  • 1
    While this code may answer the question, it would be better to include some context, explaining _how_ it works and _when_ to use it. Code-only answers are not useful in the long run. – martineau Feb 08 '22 at 02:10
0

pd.import_csv doesn't exist. You probably meant to use pd.read_csv instead.

import pandas as pd 
tbl1 = pd.read_csv('sample_prices.csv') 
tbl1.print()

That said, I'm not sure why it wouldn't raise an error...

If you have a custom function called import_csv, you'll want to call it like this:

import pandas as pd 
tbl1 = import_csv('sample_prices.csv') 
tbl1.print()

...without the pd. prefix.