Python Forum
Extracting data without showing dtype, name etc.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extracting data without showing dtype, name etc.
#1
Hello,

I have a basic question and would be happy if someone could help me out.

I've extracted the prices of 2 stocks (Varta and Softcat) from a website using the following code:

import pandas as pd
# Get data from website
url = 'https://www.ariva.de/varta-aktie/kurs'
df = pd.read_html(url)
# Select table
df_Varta = df[3]
url = 'https://www.ariva.de/softcat-aktie/kurs'
df = pd.read_html(url)
df_Softcat = df[3]
# Extract price from column/ row 
price_Varta= df_Varta['Letzter'][df_Varta['Handelsplatz']=='Xetra']
price_Softcat= df_Softcat['Letzter'][df_Softcat['Handelsplatz']=='L&S RT']

print(price_Varta)
print(price_Softcat)
The code generates the following output:

Output:
5 126,90 € Name: Letzter, dtype: object 0 16,825 € Name: Letzter, dtype: object
However, I only want to know the price (without row numbers, name or dtype). Has anyone an idea how to achieve this result?

Many thanks in advance!

Best,

Tim
Reply
#2
you need to add also .item()

price_Varta= df_Varta['Letzter'][df_Varta['Handelsplatz']=='Xetra'].item()
tgottsc1 likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Hi Buran,

great, many thanks for this - now it works perfectly!
Reply
#4
I am really not sure why you need specific item from the detaframe. Normally you would use pandas/dataframe for vectorized calculations.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Extracting Data into Columns using pdfplumber arvin 17 5,577 Dec-17-2022, 11:59 AM
Last Post: arvin
  Showing an empty chart, then input data via function kgall89 0 980 Jun-02-2022, 01:53 AM
Last Post: kgall89
  Same Data Showing Several Times With Beautifulsoup Query eddywinch82 2 1,252 May-29-2022, 11:46 PM
Last Post: eddywinch82
  Showing data change korenron 10 2,565 Mar-20-2022, 01:50 PM
Last Post: korenron
  Extracting Data from tables DataExtrator 0 1,150 Nov-02-2021, 12:24 PM
Last Post: DataExtrator
  extracting data ajitnayak1987 1 1,540 Jul-29-2021, 06:13 AM
Last Post: bowlofred
  Extracting and printing data ajitnayak1987 0 1,411 Jul-28-2021, 09:30 AM
Last Post: ajitnayak1987
  Extracting unique pairs from a data set based on another value rybina 2 2,308 Feb-12-2021, 08:36 AM
Last Post: rybina
Thumbs Down extracting data/strings from Word doc mikkelibsen 1 1,927 Feb-10-2021, 11:06 AM
Last Post: Larz60+
  Extracting data from a website tgottsc1 2 2,276 Jan-09-2021, 08:14 PM
Last Post: tgottsc1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020