Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 18819

Python: Multidimensional Arrays

$
0
0

Is this format a Multidimensional Array ?

sales=[LastSale(date=datetime.datetime(2024, 3, 10, 21, 15, 53, tzinfo=datetime.timezone.utc), price='0.59'), LastSale(date=datetime.datetime(2024, 3, 9, 16, 39, 22, tzinfo=datetime.timezone.utc), price='1.3'), LastSale(date=datetime.datetime(2024, 3, 9, 4, 59, 27, tzinfo=datetime.timezone.utc), price='0.58'), LastSale(date=datetime.datetime(2024, 3, 8, 23, 59, 45, tzinfo=datetime.timezone.utc), price='1.3'), LastSale(date=datetime.datetime(2024, 3, 7, 15, 55, 57, tzinfo=datetime.timezone.utc), price='0.9'), LastSale(date=datetime.datetime(2024, 3, 6, 14, 56, 54, tzinfo=datetime.timezone.utc), price='0.8'), LastSale(date=datetime.datetime(2024, 3, 5, 16, 55, 41, tzinfo=datetime.timezone.utc), price='1.12'), LastSale(date=datetime.datetime(2024, 3, 4, 20, 49, 50, tzinfo=datetime.timezone.utc), price='1.49'), LastSale(date=datetime.datetime(2024, 3, 3, 22, 12, 26, tzinfo=datetime.timezone.utc), price='0.6'), LastSale(date=datetime.datetime(2024, 3, 2, 8, 1, 7, tzinfo=datetime.timezone.utc), price='0.54'), LastSale(date=datetime.datetime(2024, 2, 25, 10, 6, 26, tzinfo=datetime.timezone.utc), price='0.3')]

My goal is to loop through this list and check if the item sold at least 30 times in the last 30 days. And also to calculate the average price of the last 30 days.

But I dont even know how to access this data.

This is what I tried:

test = int(last_sales["LastSale"][0].Date.timestamp())

This was the result:

TypeError: 'LastSales' object is not subscriptable

Viewing all articles
Browse latest Browse all 18819

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>