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
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.
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.
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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With