Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python cannot import DataFrame

Tags:

python

pandas

I am trying to use Pandas in Python to import and manipulate some csv file.

my code is like:

import pandas as pd
from pandas import dataframe  
data_df = pd.read_csv('highfrequency2.csv')
print(data_df.columns)

But there is an error :

ImportError: cannot import name DataFrame

I have Pandas in Python, and I think dataframe comes with Pandas.

So, anyone can tell me what does this error message mean ?

Thanks

like image 490
Tristan Sun Avatar asked Apr 19 '15 11:04

Tristan Sun


People also ask

Why I Cannot import pandas in Python?

The most frequent source of this error is that you haven't installed Pandas explicitly with pip install pandas . Alternatively, you may have different Python versions on your computer, and Pandas is not installed for the particular version you're using.

How do I import a DataFrame module in Python?

Importing data from CSV file to DataFrame Python Pandas module DataFrame can also be built using CSV files. A CSV file is basically a text file where data per line is stored in it. The elements are separated using “comma”. The read_csv(file_name) method is used to read the data from the CSV file into the DataFrame.

How do I import a DataFrame in pandas?

Using the read_csv() function from the pandas package, you can import tabular data from CSV files into pandas dataframe by specifying a parameter value for the file name (e.g. pd. read_csv("filename. csv") ). Remember that you gave pandas an alias ( pd ), so you will use pd to call pandas functions.


1 Answers

You have to use it exactly with 'DataFrame' this is really important to pay attention to the upper and lowercase characters

import pandas as pd
data_df = pd.DataFrame('highfrequency2.csv')
print(data_df.columns)
like image 60
superher0 Avatar answered Oct 13 '22 02:10

superher0