Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 loading a csv file into python from pandas. Variable is not recognized
#1
I am facing an error in loading a csv file into python with pandas package it is not recognizing a variable. Can you guys please help me out with this. Here is my csv file and the output in python. Thanks in anticipation


 brics = pd.read_csv ('C:\\Users\\amma\\AppData\\Local\\Programs\\Python\\Python37\\brics .csv', index_col=0)
	  

>>> "Country" in brics
	  
False
>>> "capital" in brics
	  
True
>>> "area" in brics
	  
True

https://drive.google.com/open?id=1T86S-f...qK4Ua35YODİmage
Quote
#2
What is question about? Is "Country in brics" expected to be True? I just loaded data and everything works fine; You have extra space in country<space> column name; It would be better to print column names out first, e.g. by calling brics.columns; and call country in brics.columns instead (Explicit is better than implicit).
Quote
#3
There were 2 issues in what u were implementing.

1. The column name "country" starts with a small 'c', whereas u were using 'C' while using the statement "Country" in brics. As python is case sensitive, this shall now be "country" in brics.

2. The column named "country" is having an extra space "country<space>" which needs to be removed.

This shall solve ur problem.

Regards
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Loading .csv data using Pandas zaki424160 1 448 Jul-15-2019, 09:48 AM
Last Post: perfringo
  Can't read text file with pandas zinho 4 1,280 May-23-2019, 05:31 PM
Last Post: zinho
  Pandas melt only on one variable (leaving other in long format) amyd 0 302 May-08-2019, 12:10 PM
Last Post: amyd
  Is there any way to properly load fixed width file into a dataframe using Pandas? vicky53 1 518 Mar-29-2019, 06:04 PM
Last Post: Larz60+
  read complex file with both pandas and not Diedro 1 541 Jan-29-2019, 05:26 PM
Last Post: Larz60+
  Load .abf file and for analysis with Pandas finalcode 0 617 Nov-10-2018, 09:51 AM
Last Post: finalcode
  Write specific rows from pandas dataframe to csv file pradeepkumarbe 3 930 Oct-18-2018, 09:33 PM
Last Post: volcano63
  JSON file Loading issue punna111 2 1,088 Aug-27-2018, 08:35 PM
Last Post: rootVIII
  Pandas - Write to Exisitng Excel File - Sorted List dj99 4 3,214 Jul-29-2018, 07:56 AM
Last Post: dj99
  Read CSV data into Pandas DataSet From Variable? Oliver 7 5,676 Jul-05-2018, 03:29 AM
Last Post: answerquest

Forum Jump:


Users browsing this thread: 1 Guest(s)